Pregunta

Tengo en mi aplicación web un archivo ADO.NET Entity-Framework * .edmx.

Cuando navego en el navegador (cuando la aplicación se está ejecutando) a un archivo edmx, no muestra la página de error como cuando navego a un archivo * .cs o vb, abre el edmx y muestra el esquema de mi modelo a todos los usuarios !!!

¿Cómo puedo evitar eso?

¿Fue útil?

Solución

Puedes hacer esto de dos maneras; primero en web.config o segundo en IIS

<system.web>
    <httpHandlers>
        <add verb="*" path="*.edmx" type="System.Web.HttpForbiddenHandler" />
    </httpHandlers>
</system.web>

Aquí hay un enlace a una página de soporte de microsoft que detalla cómo hacerlo en la configuración web e IIS.

http://support.microsoft.com/kb/815152

Otros consejos

Debe asignar la extensión a la clase System.Web.HttpForbiddenHandler de ASP.NET en web.config. Si está utilizando IIS6, antes de poder hacerlo, debería haber asignado la extensión al controlador ISAPI de ASP.NET.

Modo integrado IIS7:

<system.webServer>
    <handlers>
        <add name="MyForbiddenExtensionHandler" 
             path="*.edmx" 
             verb="*" 
             type="System.Web.HttpForbiddenHandler" 
             preCondition="integratedMode" />
    </handlers>
</system.webServer>

Modo clásico IIS7. Algo así como:

<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 (después de asignar el controlador a aspnet_isapi.dll en la configuración de IIS6):

<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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top