locked
HttpModule Dont't work On Server RRS feed

  • Question

  • User-1380475428 posted
    Hi Any one.

    I use a httpmodule for urlRewriting in my web site.

    At local i use a "SimpleRewriter" class in App_code and Set

    Webconfig as here:

    <add name="SimpleRewriter" type="SimpleRewriter, App_Code"/>

    But When i Upload my site on server it doesn't work and give Some Error as "Page Requested not found".

    I think on server asp.net doesn't have reach to my module and cant access it.

    Any help?

    Thanks.
    Friday, November 28, 2008 8:56 AM

Answers

  • User390817712 posted

    Are you using extensionless URLs like "http://server.com/mysite/orders"? A common reason for this not to work on the server running under IIS is because IIS doesn't route the request through ASP.NET for processing. How to solve this depends a bit on what version of IIS you are using. This post touches on wildcard mapping (for IIS 6) and configuration for IIS 7. http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/ 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 28, 2008 9:54 AM

All replies

  • User390817712 posted

    Are you using extensionless URLs like "http://server.com/mysite/orders"? A common reason for this not to work on the server running under IIS is because IIS doesn't route the request through ASP.NET for processing. How to solve this depends a bit on what version of IIS you are using. This post touches on wildcard mapping (for IIS 6) and configuration for IIS 7. http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/ 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 28, 2008 9:54 AM
  • User-1380475428 posted

     Thanks.

    Ii's solved.

    For iis7 we must set our module tag in webServer section.

    <system.webServer>
           
            <modules runAllManagedModulesForAllRequests="true">
               <add  name="Utils.SimpleRewriter,SimpleRewriter" type="SimpleRewriter" />
            </modules>

    </system.webServer>

     

    Friday, November 28, 2008 11:42 AM
  • User35373667 posted

    Hi

    I am facing the same problem.

    After I publish the site, http modules are not working.

    I made changes as per your suggestions, but still it is not working.

    Is there any way to set the http module working after publishing?

    Thanks in advance.

    Vinit

    Tuesday, December 9, 2008 12:28 AM
  • User-1380475428 posted

    Hi.

    Do you visit the link in answered post?

    What's your iis version?

    Do you set your proper namespace for httpModule?

    Wednesday, December 10, 2008 1:20 AM
  • User321816381 posted

    How can i set value in querystring in rewrite url.
     (e.g) I want the   http://locahost/testsite/folder1/filename1.htm  to
    rewrite into
     http://locahost/testsite/folder2/test.aspx?f=  Where i can set the
    value of f?

    Thursday, February 19, 2009 9:42 AM
  • User-1380475428 posted
    If you using httpHandler for rewriting you must rewrite url in BeginRequest function of your handle and set your new path and parameter .
    Thursday, February 19, 2009 10:10 AM
  • User321816381 posted

     Thanks For reply.

     

    In Begin Request method i am setting the Querystring ( Static property of public sealed class RewriterHttpModule : IHttpModule)  and in SetLocationAction.cs , this set value is get there.

    Begin Request()

    {

     QueryString = value;
      _rewriter.Rewrite();

    }

      public virtual RewriteProcessing Execute(RewriteContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                context.Location = context.ResolveLocation(context.Expand(Location));
                context.Location += RewriterHttpModule.QueryString;
                return RewriteProcessing.StopProcessing;
            }

    This is working fine. But in case of multiple requests at the same time this static property will remain same for all requests.

    So how can i make my application safe in multiple requests.

     

     

    Thursday, February 19, 2009 10:17 AM
  • User321816381 posted
    The value of querystring will be different for each request.
    Thursday, February 19, 2009 10:19 AM
  • User-1380475428 posted

     You may use Thread and Lock and Monitor commands.

    Thursday, February 19, 2009 10:24 AM
  • User321816381 posted

     Is it safe to lock BeginRequest. I have no idea.

    Thursday, February 19, 2009 10:32 AM
  • User321816381 posted

     Is there some other way to set the value in querystring instead of using static property?

    Thursday, February 19, 2009 10:42 AM
  • User-1380475428 posted

     In my project i send all query string as a parameter to target page(.aspx).

     

    Thursday, February 19, 2009 11:36 AM
  • User321816381 posted

     How can i decode my rules ?

     <rewrite url="~/folder1/file1.htm?x=1+%26+y=4$" to="~/folder2/default.aspx?f=" />

    In cofig i am not able to write & So i have Set %26 encoded value . How can i decode this rule ?

     

    Wednesday, February 25, 2009 2:20 PM
  • User321816381 posted

     How to use decode transform in rewrite rules?

    Wednesday, February 25, 2009 3:04 PM