It works fine with IIS 7.0 on localhost but when i upload my site and try to access the rules written for url rewrite it gives me error message of 404 ..
here is my web.config file please suggest me the require changes for Windows server 2003 IIS 6.0
I gone through the article its great. But i have one more question what if we do not have access to IIS Management console as my site is hosted on shared server and the hosting company will not allow me to access IIS management console . Is there any way
so that we can configure the IIS from our web.config?
Unfortunatley its probably time to look for a new host if thats the case. It is a common restriction with shared hosting. Have you checked with them? And looked deeply through your web hosting control panel? What company is it that you're with?
IIS6 is somewhat crippled on shared hosting.
You either need to upgrade to VPS hosting or change to an IIS7 / IIS7.5 web host because the pipeline is different and all requests are passed through asp.net no matter what the file type is. It also has an installable url rewriting module which a lot of
hosts provide pre-installed.
Yes i think so i have to change the hosting server..
But i tried with Global.asax file also their also the Begin_Request event is not getting fired on the hosting server but on local server works fine. Code of global.asax
Hmm I would have thought that the begin request is being fired just not for most of the extensions.
It should be fired for .aspx .axd, .ashx but the images and css it wont be unless you setup the mapping differently (which you can't do because you need access to the iis server in iss6)
maulik.shah8...
Member
4 Points
11 Posts
URL Rewrite not working on hosting server (Windows Server 2003, IIS 6.0)
Mar 19, 2010 05:21 AM|LINK
I have using code provided by this article :
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
It works fine with IIS 7.0 on localhost but when i upload my site and try to access the rules written for url rewrite it gives me error message of 404 ..
here is my web.config file please suggest me the require changes for Windows server 2003 IIS 6.0
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroup name="SharpEdged">
<section name="AdSense" type="AdSenseASP.NET.Configuration.AdSenseConfigSection, AdSenseASP.NET" />
</sectionGroup>
<sectionGroup name="modulesSection">
<section name="rewriteModule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule" />
</sectionGroup>
</configSections>
<modulesSection>
<rewriteModule>
<rewriteOn>true</rewriteOn>
<rewriteRules>
<rule source="([A-Za-z]+)$" destination="User.aspx?Name=$1" />
<rule source="(.+)/(\w+)/(\d+)/$" destination="Details.aspx?PID=$3" />
</rewriteRules>
</rewriteModule>
</modulesSection>
<system.web>
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="20"/>
<httpRuntime executionTimeout="110" maxRequestLength="20480" requestLengthDiskThreshold="80" useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000" enableKernelOutputCache="true" enableVersionHeader="true" apartmentThreading="false" requireRootedSaveAsPath="true"
enable="true" sendCacheControlHeader="true" shutdownTimeout="90" delayNotificationTimeout="5" waitChangeNotification="0" maxWaitChangeNotification="0" enableHeaderChecking="true" />
<pages enableSessionState="true">
<controls>
<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
</compilation>
<httpHandlers>
<remove path="*.asmx" verb="*" />
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add path="image.ashx" verb="*" type="XMLLab.WordXMLViewer.ImageHandler, XMLLab.WordXMLViewer" />
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="RewriteModule" type="RewriteModule.RewriteModule, RewriteModule" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</httpModules>
<customErrors defaultRedirect="404.aspx" mode="Off">
<error statusCode="404" redirect="404.aspx" />
<error statusCode="303" redirect="404.aspx" />
</customErrors>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="RewriteModule1" preCondition="integratedMode" type="RewriteModule.RewriteModule, RewriteModule" />
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
</configuration>
URL Rewrite Url Rewrite on IIS 6.0
rtpHarry
All-Star
56620 Points
8958 Posts
Re: URL Rewrite not working on hosting server (Windows Server 2003, IIS 6.0)
Mar 19, 2010 11:26 AM|LINK
Hi,
Your rewrite rules are attempting to use extensionless urls. By default only .aspx urls and some others are mapped to the asp.net runtime.
You will need to follow the IIS6 setup guide at the bottom of the article to get this working. Its called setting up wildcard mapping.
This is another guide which I normally point people to:
maulik.shah8...
Member
4 Points
11 Posts
Re: URL Rewrite not working on hosting server (Windows Server 2003, IIS 6.0)
Mar 19, 2010 01:59 PM|LINK
Thanks for the reply harry..
I gone through the article its great. But i have one more question what if we do not have access to IIS Management console as my site is hosted on shared server and the hosting company will not allow me to access IIS management console . Is there any way so that we can configure the IIS from our web.config?
Thanks..
IIS 6.0 url rewrite
rtpHarry
All-Star
56620 Points
8958 Posts
Re: URL Rewrite not working on hosting server (Windows Server 2003, IIS 6.0)
Mar 19, 2010 09:32 PM|LINK
Unfortunatley its probably time to look for a new host if thats the case. It is a common restriction with shared hosting. Have you checked with them? And looked deeply through your web hosting control panel? What company is it that you're with?
IIS6 is somewhat crippled on shared hosting.
You either need to upgrade to VPS hosting or change to an IIS7 / IIS7.5 web host because the pipeline is different and all requests are passed through asp.net no matter what the file type is. It also has an installable url rewriting module which a lot of hosts provide pre-installed.
maulik.shah8...
Member
4 Points
11 Posts
Re: URL Rewrite not working on hosting server (Windows Server 2003, IIS 6.0)
Mar 20, 2010 06:17 AM|LINK
Yes i think so i have to change the hosting server..
But i tried with Global.asax file also their also the Begin_Request event is not getting fired on the hosting server but on local server works fine. Code of global.asax
void Application_BeginRequest(object sender, EventArgs e)
{
string fullOrigionalpath = Request.Url.ToString();
if (!fullOrigionalpath.Contains(".aspx") && !fullOrigionalpath.Contains(".jpg") && !fullOrigionalpath.Contains(".png") && !fullOrigionalpath.Contains(".gif") && !fullOrigionalpath.Contains(".axd") && !fullOrigionalpath.Contains(".ashx") && !fullOrigionalpath.Contains("?") && !fullOrigionalpath.Contains("&") && !fullOrigionalpath.Contains(".css"))
{
string[] url = Request.Url.ToString().Split('/');
Context.RewritePath("UserPortal.aspx?Name=" + url[url.Length - 1], false);
}
}
Do i need to do any modification in Web.config? On internet i found that this code works for IIS 6.0 also..but its not..
Url Rewrite on IIS 6.0
rtpHarry
All-Star
56620 Points
8958 Posts
Re: URL Rewrite not working on hosting server (Windows Server 2003, IIS 6.0)
Mar 20, 2010 01:56 PM|LINK
Hmm I would have thought that the begin request is being fired just not for most of the extensions.
It should be fired for .aspx .axd, .ashx but the images and css it wont be unless you setup the mapping differently (which you can't do because you need access to the iis server in iss6)