I have in my web application an ADO.NET Entity-Framework *.edmx file.
我在我的Web应用程序中有一个ADO.NET Entity-Framework * .edmx文件。
When I browse in the browser (when the application is running) to an edmx file, it doesn't show the error page like when browsing to a *.cs or vb file, it opens the edmx and shows my model scheme to all the users!!!
当我在浏览器中浏览(当应用程序运行时)到edmx文件时,它不会显示错误页面,就像浏览到* .cs或vb文件一样,它会打开edmx并向所有人显示我的模型方案用户!
How can I avoid that.
我怎么能避免这种情况。
2 个解决方案
#1
8
You can do this two ways; firstly in the web.config or secondly in IIS
你可以这两种方式做到这一点;首先在web.config中,或者在IIS中
<system.web>
<httpHandlers>
<add verb="*" path="*.edmx" type="System.Web.HttpForbiddenHandler" />
</httpHandlers>
</system.web>
Here's a link to a microsoft support page that details how to do it in the web config and IIS.
这是微软支持页面的链接,详细说明了如何在Web配置和IIS中执行此操作。
http://support.microsoft.com/kb/815152
http://support.microsoft.com/kb/815152
#2
10
You should map the extension to the ASP.NET's System.Web.HttpForbiddenHandler
class in web.config
. If you are using IIS6, before you could do that, you should have mapped the extension to ASP.NET ISAPI handler.
您应该将扩展名映射到web.config中的ASP.NET的System.Web.HttpForbiddenHandler类。如果您使用的是IIS6,则必须先将扩展名映射到ASP.NET ISAPI处理程序。
IIS7 Integrated Mode:
IIS7集成模式:
<system.webServer>
<handlers>
<add name="MyForbiddenExtensionHandler"
path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler"
preCondition="integratedMode" />
</handlers>
</system.webServer>
IIS7 Classic Mode. Something like:
IIS7经典模式。就像是:
<system.web>
<httpHandlers>
<add path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="MyExtensionISAPI"
path="*.edmx"
verb="*"
modules="IsapiModule"
scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
</handlers>
</system.webServer>
IIS6 (after mapping the handler to aspnet_isapi.dll
in IIS6 configuration):
IIS6(在IIS6配置中将处理程序映射到aspnet_isapi.dll之后):
<system.web>
<httpHandlers>
<add path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>
#1
8
You can do this two ways; firstly in the web.config or secondly in IIS
你可以这两种方式做到这一点;首先在web.config中,或者在IIS中
<system.web>
<httpHandlers>
<add verb="*" path="*.edmx" type="System.Web.HttpForbiddenHandler" />
</httpHandlers>
</system.web>
Here's a link to a microsoft support page that details how to do it in the web config and IIS.
这是微软支持页面的链接,详细说明了如何在Web配置和IIS中执行此操作。
http://support.microsoft.com/kb/815152
http://support.microsoft.com/kb/815152
#2
10
You should map the extension to the ASP.NET's System.Web.HttpForbiddenHandler
class in web.config
. If you are using IIS6, before you could do that, you should have mapped the extension to ASP.NET ISAPI handler.
您应该将扩展名映射到web.config中的ASP.NET的System.Web.HttpForbiddenHandler类。如果您使用的是IIS6,则必须先将扩展名映射到ASP.NET ISAPI处理程序。
IIS7 Integrated Mode:
IIS7集成模式:
<system.webServer>
<handlers>
<add name="MyForbiddenExtensionHandler"
path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler"
preCondition="integratedMode" />
</handlers>
</system.webServer>
IIS7 Classic Mode. Something like:
IIS7经典模式。就像是:
<system.web>
<httpHandlers>
<add path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="MyExtensionISAPI"
path="*.edmx"
verb="*"
modules="IsapiModule"
scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
</handlers>
</system.webServer>
IIS6 (after mapping the handler to aspnet_isapi.dll
in IIS6 configuration):
IIS6(在IIS6配置中将处理程序映射到aspnet_isapi.dll之后):
<system.web>
<httpHandlers>
<add path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>