Re: BUG? With A HTTPModule

From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 03/30/04


Date: Tue, 30 Mar 2004 05:58:48 GMT

Hi,

>From your descritption, you used a HttpModule to perform Url ReWriting
according to the querystring in the original requested url(checking them in
the BeginRequest event). However, you found this worked when the certain
querystring is specified but encountered 404 error if request the url
without any querystring such as somepage.aspx , yes?

As for this issue, I've some further questions on it:
1. Are the pages you encountered problem in a IIS server's root folder or
in a Virtual directory?

2. You may have a try comment the "Context.RewritePath" code line and
replace it by the
Response.Write(...)
Response.End()
to see whether this can work?

3. Does the problem occur if you hard code the "newUrl" which used in the
Context.RewritePath? And since when 404 error occur when processing a aspx
page, the error info will contains the certain actually requested page's
path such as below:
===============================
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure that
it is spelled correctly.

Requested Url: /FormAuthApp/controls/WebForm1.aspx
====================================
Have you checked the actual path displayed in the above's "Requested Url"
to see whether it is a invalid path or is a existing page path?

In addition, I've generated a simple test on my side, on WIN XP PRO
machine, with ASP.NET1.1 and IIS5, the web application is in a certain
virtual directory. I added a simple HTTPModule as below:
=============================
public class RedirectModule : IHttpModule
        {
                private HttpApplication httpApp;

                public void Init(HttpApplication httpApp)
                {
                        this.httpApp = httpApp;
                        httpApp.BeginRequest += new EventHandler(OnBeginRequest);
                }

                void OnBeginRequest(object sender, EventArgs a)
                {
                        HttpApplication application = (HttpApplication)sender;
                        HttpRequest request = application.Context.Request;
                        HttpResponse response = application.Context.Response;
                        string newUrl = "WebForm1.aspx";

                        try
                        {
                                if (request.QueryString["id"]!=null)
                                {
                                        newUrl = newUrl + "?id=" + request.QueryString["id"];
                                }
                        }catch (Exception ex)
                        {
                                response.Write("<br>"+ ex.Message);
                        }

                        application.Context.RewritePath(newUrl);

                }

                public void Dispose()
                {}
        }

I tried visit some pages (which is in the root folder of the application)
both with querystring and without any querystring but seems not encounter
the problem. So I think it'll be more helpful if you can provide a detailed
repro description , for example:
Applicaiton's virutal folder path:
page position, complete code in the HTTPModule and steps to repro the
problem.

Thus, I'll be able to do some futher research on my side. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx



Relevant Pages

  • Re: Alter querystring through APP
    ... In my Startmethod I am appending the querystring to szUrl ... The request gets sent with the new url. ... In my ReportData() method my App calls targetSink's ReportProgress ... right before calling Start on target APP. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Alter querystring through APP
    ... In my Startmethod I am appending the querystring to szUrl ... The request gets sent with the new url. ... In my ReportDatamethod my App calls targetSink's ReportProgress ... the browser sends to APP a request without the ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: HttpWeb Request from Class Library fails to 500
    ... I also used IE UserAgent string. ... querystring that you pass. ... > I agree with Joerg, since the IIS server has received the request, it is ... > some further detailed info on the asp.net page you request... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: adding an item to a QueryString
    ... > It doesn't really make a lot of sense to change a property of a request ... the site use a different stylesheet if "Mode2" is in the Querystring. ... present in the referrer, the value could be propagated at a high level, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: KB835732 not installing
    ... The strangely was in regards to free$$$. ... and I have yet to encounter a request for 'contributions'. ...
    (microsoft.public.windowsxp.general)

Quantcast