Response.Redirect passes the ISAPI_Rewrite engine - asp.net

*I use ISAPI_Rewrite v2
Hi,
So I implement ISAPI_Rewrite on my site.
Now i put on my pages a Response.Redirect
But as it seems the redirect passes the ISAPI engine..
i.e. I see the new url but the rule doesnt apply.
for example i enter this:
example.com/SomePage.aspx
in SomePage.aspx.cs - PageLoad function theres:
Response.Redirect("/Page");
So I get redirected to example.com/Page
But it says to me "This link appears to be broken"
on httpd.ini I have this rule
RewriteRule ^/Page$ /Page.aspx [L]
My guess is that the Response.Redirect doesnt go through
the ISAPI_Rewrite...
How can I fix this??
Thanks
=====
edit:
solved, the hebrew chars was the problem, you need to encode them first.

if you do response.redirect the whole page life cycle is working. All the modules are called as usual. So maybe the rewrite module does not get called?
Did you put some breakpoints in the module so that you know if it gets called or not?
have you set up your module somewhere in your webapp?

Related

URL Rewriting in IIS7 annoyingly adds folder name to url

I'm having trouble with my URL Rewriting; IIS keeps adding the folder name to the url.
E.g. my.site.com/Login/ gets re- written to my.site.com/MY/Login
The frustrating thing is that the my.site.com/Login/works but whenever a link is clicked it adds the /MY/ to the url.
Does anyone know how to resolve this?
Existing re-write rule: (http(s)?:\/\/)?my.site.com
Rule I'm playing with (not finished) to try and detect the /MY/ and redirect to the 'proper' url
(http(s)?://)?(www.)?my.site.com/MY/
Thanks!

ASP/VBSCRIPT URL Trailing dots issue

i've got a problem whereby some websites linking into mine have truncated the URL with trailing dots, 3 of them to be exact!
eg. http://www.mywebsite.com/7542-this-is-a-link-to...
The url should be http://www.mywebsite.com/7542-this-is-a-link-to-my-website.html
Naturally, ISAPI rewrite doesn't understand the truncated url so I need to do a redirect to the correct url using a 301 redirect
Something like:
RewriteRule ^7542-this-is-a-link-to... /7542-this-is-a-link-to-my-website.html [L,R=301]
But for the life of me I cannot get ISAPI rewrite to match against the 3 dots, annoyingly the incorrect URL doesn't even 404 redirect! I have no idea where it is going to... Just a blank screen so am guessing it has something to do with IIS web.config file...
Please help me before I become balder than I already am!
The could be several different reasons for that. Basically the rule like:
RewriteRule ^7542-this-is-a-link-to.* /7542-this-is-a-link-to-my-website.html [L,R=301]
would fix the problem, matching everything after "-to". But it's not ISAPI_Rewrite that throws 404. It's IIS. I had issues before and all googling ended up with IIS blocking suspicious characters. Try to tweak that.
It could be this "dots in the URL"
This thread has a lot of useful info
I'm totally ignorant of Microsoft internet tech, but is there any chance that the three dots in the incoming URL are actually a single "ellipsis" character (… not ...)? If so, you'd need to use that character in your RewriteRule. You'd have to check the docs to know how to correctly encode that character for the config file.

Regex on URL rewrite module

I need a help with Regex on URL rewrite module.
I want to apply a rule for the home page.
I tried with ^default.aspx, which is working fine when user access the site with /default.aspx
But normally users are accessing the site with / (www.website.com/) so I am trying to write the reqex and not able to find the correct one.
I tried lot of different combination but nothing worked so far.
^(/default.aspx|$|/$)
^(|/|/default.aspx)
Thanks for the help
You could use the following pattern:
^(/|default.aspx)?$
It will match /, default.aspx or nothing

Why won't postbacks work on my domain root?

I have a form on a masterpage which is very simple but will not work when the site is at the root.
Works fine:
www.mysite.com/page.aspx
www.mysite.com/another/page.aspx
Does not work:
www.mysite.com
I click the button and it postsback to
www.mysite.com/default.aspx
But nothing has executed, now if I try the form again on /default.aspx it will postback and execute fine.
What am I doing wrong?
It sounds to me like the default page redirection is either accidentally (or intentionally) losing all form data. I would first suggest not redirecting to a page that doesn't exist.
However, if you insist, I'd try something like URL rewriting. Hopefully a rewrite from a module will keep the form data intact, but I can't say for sure it will. Good luck!
Thanks for the reply, I just figured it out!
I am using isapi to make sure my urls are all lower case, and 301 redirecting any upper case URL's to their equivalant lowercase version.
On postback its action is Default.aspx ... My script was redirecting it to default.aspx and loosing the values before it was posted back.. DOH!
Do you have an Index.aspx at the root of your site?

Subdomain to point to subdirectory of main site?

I have my website running at:
www.example.com
I also have this other domain:
www.example.net
Is it possible to point "www.example.net" to a subdirectory of "www.example.com"? For example:
www.example.net-> www.example.com/other
?
It's not just a redirect, I need to serve the pages and see "www.example.net" in the user's browser.
What do you think?
We use IIS7 and everything is ASP.NET (aspx pages, ascx controls, etc).
Using ISAPI Rewrite
[ISAPI_Rewrite]
RewriteCond Host: (?:www\.)?other\.com
RewriteRule (.*) http://www.domain.com/other$1 [I,L]
You're looking at two methods for this:
URL rewriter
Server.Execute method
The first is a httpmodule that silently redirects the request without changing the url in the address bar, the second is a method you can call within aspx code. I think the latter is only good though if you're working in the same application, so I would go with the URL rewriter.
There is an official iis7 URL rewriter available on www.iis.net afaik.
-Oisin
Two questions for you:
Can you set them up as two different web sites in IIS?
If someone visited example.net/page.htm, would that be the same as example.com/other/page.htm?
If the answer is yes to both of those, why not just setup a new web site in IIS and point it to the "other" file path.

Resources