locked
Url ReWriting setting up in web.config RRS feed

  • Question

  • User906176758 posted

    Hi All,

    Currently I have a wildcard mapping to aspnet_isapi.dll in Win2003 IIS 6. I'd prefer to remove it from there and have it in my web.config. Is this possible?

    I use custom module for url rewriting. I exclude all CMS workarea files and folder from custom urlrewriting module.  If i have remove widcard configuartion in IIS6.0 drag and drop works and url rewriting not woking. Can any one help for me.

    sub application_beginrequest()

    If (Request.Url.ToString().ToLower().Contains("workarea") Or Request.Url.ToString().ToLower().Contains("aspnet_client") Or Request.Url.ToString().ToLower().Contains("assetmanagement") Or       Request.Url.ToString().ToLower().Contains("assets") Or Request.Url.ToString().ToLower().Contains("privateassets") Or Request.Url.ToString().ToLower().Contains("bin")) Then
    Else
              Rewrite(Request.RawUrl)
    End If
    End Sub

     the above configuration setting works fine with Windows XP. I need to use wildcard configuration in WEB.config to work the URL Rewriting.


    Thanks in Advance

    Saravanan.R
     

    Thursday, August 9, 2007 8:02 AM

Answers

  • User-225114762 posted

    Currently I have a wildcard mapping to aspnet_isapi.dll in Win2003 IIS 6. I'd prefer to remove it from there and have it in my web.config. Is this possible?

    Short answer: No. It's not possible. You must have a wild card mapping to make URL rewriting work.

    Long answer: For your HttpModule to get a chance to do anything, ASP.NET must be called with the request. IIS is the program calling ASP.NET for certain requests. It determines which requests to call ASP.NET for via extension-mapping, i.e. .aspx is mapped to ASP.NET and thus results in IIS calling ASP.NET. Most URL rewriting is about rewriting extension-less request paths. By definition, a wild-card mapping in IIS is the only way to tell IIS to call ASP.NET (or any other isapi extension). So - to make this work, you must have a wild-card mapping (and you must also uncheck the 'check that file exist' checkbox).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2007 1:02 PM

All replies

  • User-900677162 posted

    HI,Saravanan.R:

    I recommend you to check this article about Url rewritting in asp,net

    http://www.codeproject.com/aspnet/URLRewriter.asp

     

    Sunday, August 12, 2007 11:08 PM
  • User-225114762 posted

    Currently I have a wildcard mapping to aspnet_isapi.dll in Win2003 IIS 6. I'd prefer to remove it from there and have it in my web.config. Is this possible?

    Short answer: No. It's not possible. You must have a wild card mapping to make URL rewriting work.

    Long answer: For your HttpModule to get a chance to do anything, ASP.NET must be called with the request. IIS is the program calling ASP.NET for certain requests. It determines which requests to call ASP.NET for via extension-mapping, i.e. .aspx is mapped to ASP.NET and thus results in IIS calling ASP.NET. Most URL rewriting is about rewriting extension-less request paths. By definition, a wild-card mapping in IIS is the only way to tell IIS to call ASP.NET (or any other isapi extension). So - to make this work, you must have a wild-card mapping (and you must also uncheck the 'check that file exist' checkbox).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2007 1:02 PM
  • User906176758 posted

    Thanks svante,

     
    The same coding and other setup i was done in my XP System, except wildcard mapping with application in IIS. Instead of mapping in IIS I have done through WEB.CONFIG. it works in windows XP system.

     Why let me know ?

     

    Thanks

    Saravanan.R
     

    Monday, August 13, 2007 2:29 PM
  • User-225114762 posted

    I think you're saying that despite all it actually works in your Windows XP system.

    My guess is that it works because you're running the Development Web Server in Visual Studio 2005 - it always has wild-card mapping enabled.

    Monday, August 13, 2007 2:38 PM
  • User906176758 posted

    no. i don't think so. because i have config the wild-card mapping in windows XP system. After that i have remove that settings and given those setting in WEB.CONFIG.

    If so means how could i enabled the wild-card mapping by default in Windows 2003 Server. 

    Monday, August 13, 2007 2:50 PM
  • User-225114762 posted

    I think we have a natural language problem here I'm afraid, and we're talking around each other.

    - To be able to work in ASP.NET with a URL that does not have an extension, such has http://www.myserver.com/mypath/mywhatever you *must* have a wild-card mapping enabled in the web server. In Windows XP, this is IIS 5 or the Development Web Server. In Windows 2003 this is IIS 6 or the Development Web Server. The Development Web Server *always* has wild-card mapping enabled. IIS 5 and IIS 6 *require* you to manually configure this.

    - You can perform limited URL Rewriting without any IIS configuration if the URL in question already is mapped to ASP.NET. In practice I've never actually seen any application where this suffices.

    - You say you have "remove that settings and given those setting in WEB.CONFIG" in your Windows XP / IIS 5. Can you please show just exactly what you have added to Web.Config ?

    Monday, August 13, 2007 3:44 PM
  • User906176758 posted

    Thanks svante.

    Here the following code that what we included in web.config and remove the wildcard configuration in windows XP/ IIS 5.1.

    <system.webServer>
            <handlers accessPolicy="Script, Execute, Read">
                <remove name="ISAPI-dll"/>
                <add name="ISAPI-dll" path="*.dll" verb="*" type="" modules="IsapiModule" scriptProcessor="" resourceType="File" requireAccess="Execute" preCondition="" allowPathInfo="true"/>
            </handlers>
    </system.webServer>

    The same above code is not working in Windows 2003 Server / IIS 6.0. We don't know why ? whether we have to set any optional param. or else ?

     

    Assisst me in this regard.

    Thanks

    Saravanan.R
     

     

     


    Tuesday, August 14, 2007 1:14 AM
  • User-225114762 posted

    Here the following code that what we included in web.config and remove the wildcard configuration in windows XP/ IIS 5.1.

    No you did not. You did that in Windows Vista/IIS 7. At least if it is to have any potential of effect. The <system.webServer> element is only supported in Windows Vista/IIS 7. IIS 7 adds a whole new level of integration between IIS and ASP.NET, and there you indeed can as you have found out do things affecting IIS via Web.Config.

    Although my personal experience in IIS 7 is limited, from reading the documenation it does not appear that this is a wild-card mapping either. It appears to map all requests to paths to files with the extension ".dll" to the IsapiModule, which is fair enough - and identical to the the default configuration.

    To summarize:

    The addition you have made to <system.webServer> element in Web.Config has the following effect for the different Web Servers:

    Windows XP/IIS 5 - None. The <system.webServer> element is not recognized, and thus ignored.

    Windows 2003/IIS 6 - None. The <system.webServer> element is not recognized, and thus ignored.

    Windows Vista/IIS 7 - None. The change is identical to the default configuration.

    Visual Studio 2005/Development Web Server - None. The <system.webServer> element is not recognized, and thus ignored.

    I should also add that if your question had related to IIS 7, then I do believe that you can do your wild-card mapping in Web.Config (but not like you tried above).

    Tuesday, August 14, 2007 2:01 AM
  • User906176758 posted

    thanks for reply,

     

    I need both functionalities (url rewrtiing and drag & drop).In our cms we have the drag and drop functionalities.But when i try url rewriting "wildcard configuration" drag and drop not supported.This "wildcard  configuration" affects static files.Is there any solutions or any changes needed  in web.config file when we use wild card configuration.Can u suggest me that one.

     

    with regards,

    Saravanan 

    Tuesday, August 14, 2007 2:38 AM
  • User-225114762 posted

    This "wildcard  configuration" affects static files.

    Yes, it does. In normal situation, IIS serves many files directly such as .html, .gif, .jpg etc. This is done without any interaction by ASP.NET. ASP.NET never even sees the request.

    When you do enable wild-card mapping, ASP.NET sees - and must handle all these requests as well. ASP.NET has a HttpHandler called StaticFileHandler that must be wired up to handle these files, which it normally does via the default configuration. Typically there's no need to change any Web.Config configuration of static files when enabling wild-card mapping. You might want to add some code to add a caching policy to the files served via the StaticFileHandler though if I recall correctly. This is only an optimization issue, not a functional issue.

    Just what is the problem? ("Not working" is insufficient as problem description ;-). I suggest you get FireBug for FireFox, or IEWatch for Internet Explorer, or Fiddler for any browser to determine any problems in the flow of requests and responses between the client and the server.

    Tuesday, August 14, 2007 3:14 AM
  • User-29125338 posted

    How can I enabled wild-card mapping in IIS7/Vista and IIS6/W2003?
    Its's possible to do in web.config?

    Regards

    Friday, September 21, 2007 1:05 PM
  • User-29125338 posted

    At IIS7/Vista I solve with this code in my Web.config:
    <system.webServer>
      <modules>
        <add name="Rewriter" type="Rewriter" />
      </
    modules>
    </system.webServer>

    Now, how can I solve in IIS6?

    Friday, September 21, 2007 2:59 PM