Click here to Skip to main content
15,905,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)

I have done some code for url rewriting but issue is its working fine with localhost. But it shows an error (404) online. Tell me what changes need to make in web.config file?

Addition from duplicate question:

please see this url

Please suggest me required changes in web.config file.

Web.config File
<?xml version="1.0"?>
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
    <add name="sqlcn" connectionString="Data Source=***;database=lovejayg_DBannualReport;uid=***;Pwd=***"/>
    <customErrors mode="Off" redirectMode="ResponseRewrite"/>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
    <authentication mode="Windows"/>
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
    <rewrite url="~/Article/(.+)-(.+).aspx" to="~/DynamicPage.aspx?MyTitleId=$2"/>
Updated 27-May-12 4:15am

1 solution

Check application pool identity settings and make sure that your web application's appPool Identity is set ApplicationPoolIdentity and Managed Pipeline Mode as Integrated.

Then check your web config system.webserver modules and enable this configuration on your application web config.
<system.webserver><modules runallmanagedmodulesforallrequests="true"> </modules></system.webserver>

Fixing 404 errors on invalid URL’s with ASP.NET’s URL Rewrite

How to do a rewrite rule in web.config
URL Rewriting in ASP.NET
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900