I'm using asp.net 4 routing in one of our new product and it works fine in the development environment (Visual studio webserver). but when i moved it to remote iis for testing purpose it doesn't work. all i get is 404 error page. i tried adding the following to the web.config and still getting the error.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
any ideas how to sort this issue?.
i got the solution for this ... add the below code in ur web.config ..
and dont forget to add runAllManagedModulesForAllRequests="true" in your module..
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add
name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*" path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
</system.webServer>
Note: You have to set Application Pool to Asp.net 4.0 application pool , as routing is not working with Asp.net 4.0 Classic Application pool.
Related
I have set up URL Routing in IIS. When I have the runAllManagedModulesForAllRequests set to true, the URL routing works.
With the following web.config (and runAllManagedModuesForAllRequests set to false) I get a 404:
<system.web>
<compilation defaultLanguage="c#" debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="UrlRoutingHandler" />
<add name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*"
path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler,
System.Web, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<modules>
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing,
Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</modules>
</system.webServer>
How do I set up URL Routing for only certain requests?
I have tested this configuration in IIS 7.5 and IIS 8. This is in a web forms application. All URLs demonstrate the 404 behavior.
"runAllManagedModulesForAllRequests" being true, means that the asp.net handler (of course when you are in integrated mode) will fire for all extensions (including extension-less), if you don't have aspx and it's set to false your module can't process it.
You can't setup for a subset of extensions for what you are trying to achieve, but you can in the module filter it yourself to only handle certain extensions.
Recently we created a Windows Instance on Amazon EC2 and deployed our application.
Everything is working fine except URL Routing. For this I have googled everything and tried all the possible options right from changing the web.config, making sure HTTP Redirection feature is on in IIS and many other things but nothing seems to work it simply gives me 404 page not found.
My final web.config is looking like this beside the other required data
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
<directoryBrowse enabled="false"/>
</system.webServer>
Can I know what is that, which I am missing as I have tested out all the options and nothing is working.
I uses asp.net 3.5 for buiding my application,
I use URL routing in it and it works fine in my local host
In my web.config file i do the following setting
<system.web>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="UrlRoutingHandler"/>
<add name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*" path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler,
System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
But when i deploy the application on my server which has IIS 7 and windows 2008 r2 then routing doesn't work there.I think i have to do some iis setting or to change some web.config code....
so please anyone suggest me some answer
Have you thought about implementing Page Routing from you web-app?
One problem that you might incur, is if your using AJAX (Toolkit or Extensions) you will need to implement:
'Ignores any Resource cache references, used heavily in AJAX interactions.
rts.Ignore("{resource}.axd/{*pathInfo}")
To keep from getting Sys is undefined errors while debugging.
I'm programming ASP.NET using visual studio 2010 and IIS 7.5
I have URL-rewriting in Global.asax (RouteTable.Routes.MapPageRoute). It works in Development Server but not in IIS.
Is there a configuration for this in IIS?
There's a webconfig for it... You don't need the remove/add part, that's just showing how you'd explicitly only include this module.
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
system.web:
<httpModules>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
I have in my web application an ADO.NET Entity-Framework *.edmx file.
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!!!
How can I avoid that.
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.
IIS7 Integrated Mode:
<system.webServer>
<handlers>
<add name="MyForbiddenExtensionHandler"
path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler"
preCondition="integratedMode" />
</handlers>
</system.webServer>
IIS7 Classic Mode. Something like:
<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):
<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>
You can do this two ways; firstly in the web.config or secondly in 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.
http://support.microsoft.com/kb/815152