|
| HttpModule for UrlRewriting: Does not work on IIS 6, but works on ASP Dev Web Server |
 |
Thu, 6 Mar 2008 16:11:17 +0000 |
Hi,
I tried to program my first HttpModule for URL rewriting according to Scotts
Video "How Do I: Implement URL Rewriting?" on
http://asp.net/learn/videos/video-154.aspx
On my development machine with Visual Studio 2008 and the ASP Deveopment Web
Server, the URL Rewriting works perfect.But as soon as I deploy it on my
production server with Windows 2003 Server and IIS 6, the rewritten URLs lead to
a HTTP 404 error. It seems that the rewriting doesn't work and the events don't
get fired.
Here is my code, for this experiment I try to rewrite/redirect every request to
the Default.aspx page:
1 public class UrlRewriting : IHttpModule
2 {
3 private const int StelleBefehl = 1;
4 5 void context_BeginRequest(object sender, EventArgs e)
6 {
7 // Vorbereitungen8 HttpApplication app =
(HttpApplication)sender;
9
10 app.Context.RewritePath( "/Default.aspx",
"", "");
11 }
12 13 14 public void Dispose()
15
17 18 19 public void Init(HttpApplication context)
20 {
21 context.BeginRequest += new
EventHandler(context_BeginRequest);
22 }
23 }
I did not forget to register the module in web.config
1 <httpModules>
2 <add name="UrlRewriting" type="MyLib.UrlRewriting,
MyLib"/>
3 </httpModules>
Is there any fundamental to think of what I did wrong? How would you check and
find the error?
Thanks in advance,
Hannes
|
| Post Reply
|
| Re: HttpModule for UrlRewriting: Does not work on IIS 6, but works on ASP Dev Web Server |
 |
Thu, 6 Mar 2008 16:22:58 +0000 |
Hi,
i reaaly don't know how to help u,the only thing I can do 4 you is watch the
video again and report to U later...
U are brazilian?
"pq se vc for brasileiro fica até mais facil de tentar te
ajudar...."
>.<
later
|
| Post Reply
|
| Re: HttpModule for UrlRewriting: Does not work on IIS 6, but works on ASP Dev Web Server |
 |
Thu, 13 Mar 2008 06:24:56 +000 |
hannesBrazil:7 // Vorbereitungen8 HttpApplication app =
(HttpApplication)sender;
9
10 app.Context.RewritePath( "/Default.aspx", "",
"");
Hi Hannes,
This line works:
app.Context.RewritePath( "Default.aspx", "", "");
This is because the virtual path is not allowed to map to another application.
|
| Post Reply
|
| Re: HttpModule for UrlRewriting: Does not work on IIS 6, but works on ASP Dev Web Server |
 |
Wed, 19 Mar 2008 12:00:03 +000 |
Hi Zhao,
thank you for your awnser. I have corrected the error you mentioned. But I
think there must be another error, because I did not sucessfully rewrite my
urls.
For a test, I thow an exception right after the line
void context_BeginRequest(object sender, EventArgs e)
{
throw new Exception( "I am in BeginRequest" );
}
So the IIS is jumping into this method when I navigate to my Default.aspx page:
http://1.2.3.4/Default.aspx
So far so good. But as soon as I request a URL that should be rewritten, e.g.
http://1.2.3.4/RewriteThis
the method "context_BeginRequest" is NOT being called, instead I get
my HTTP 404 error.
Any suggestions?
Regards,
Hannes.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|