Why won't postbacks work on my domain root? - asp.net

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?

Related

301 redirect from classic ASP with parameter to ASP.net page on Volusion

I need to redirect 1000's of URL's of the following format:
http://egauges.com/vdo_mult3.asp?Type=Ammeter&Series=Vision&Units=E
to a new Volusion (unfortunately) ASP.net site with the format
egauges.com/Ammeters-s/22044.htm
Which is actually here for now (http://gnqvn.mzqlg.servertrust.com/Ammeters-s/22044.htm)
The old site will go away once this is working, so redirects must be done on the new site.
Volusion has a 301 redirect "tool", but unfortunately it can't handle anything after the ? in the original URL. Volusion kicked it up the chain in their tech support, but says there isn't a way to do it. I'm sure some sort of script, either server or client side, or maybe even something simpler would work, but despite searching high and low, I can't figure it out.
Thanks!
Dave
Do the redirect directly in the asp site.
Change vdo_mult3.asp so that it redirects anyone who accesses it by using Response.Redirect as follows:
Response.Redirect("http://egauges.com/Ammeters-s/22044.htm")
You can also check the parameters passed to and change the redirect passed on those parameters.

Response.Redirect passes the ISAPI_Rewrite engine

*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?

how to force to default.aspx instead of www.domain.com

OK. I'm having a ridiculous problem. I'm trying to use URL rewrite to redirection from www.domain.com to www.domain.com/default.aspx.
I thought by setting default.aspx as the default document it would automatically drop the user there. But for some reason it still comes up www.domain.com.
The reason I want it to go to www.domain.com/default.aspx is that the login control on the page doesn't seem to want to work when it is just the www.domain.com. But of course if I type in the www.domain.com/default.aspx then the login works fine. The login control doesnt seem to post at all if it is www.domain.com. Anyway, I'm trying to avoid troubleshooting why the login control is not firing and just force it to land on default.aspx anytime someone tries to go to www.domain.com. I'm using IIS7. Any ideas here?
You could add something like this to your Default.aspx code behind (in your Page_Load method):
if (Request.Url.LocalPath == "/")
{
Response.Redirect("~/Default.aspx");
}
Note that the default document setting normally allows that page to be displayed under www.domain.com/ and www.domain.com/default.aspx (it doesn't do any redirecting for you).
The anwer has to do with a breaking change in ASP.NET 4. Answer was that the form action was empty action="" when on extensionless root url. but if on that same page, but had the name of the page in the url (blahblah.com/default.aspx) the action gets filled in. the easy fix for me was to put Me.Form.Action = "Default.aspx" on the page load of the home page. problem fixed.

Possible bug/issue in ASP.NET 3.5 related to Request.RawUrl property

I posted a query for 301-redirect using ASP.NET 3.5 here:
Redirecting default.aspx to root virtual directory
Based on the replies I got there, I realized there might be a bug in ASP.NET's Request.RawUrl method which is unable to return the actual raw url (without /default.aspx) when being used in a sub-directory, i.e. the /default.aspx page is inside a subdirectory.
Can someone please shed some light on this possible bug?
Thanks,
Asif
i found a good explanation here
http://codeasp.net/blogs/vivek_iit/microsoft-net/873/301-redirect-from-default-aspx-to-site-root
Thanks
If you suspect this is a bug, then the place to go is Microsoft Connect, where you can report and discuss the bug directly with Microsoft.
Edit: I was able to reproduce the look per your comments.
I was unable to reproduce the infinite loop, however. I injected code into the Global.asax Application_BeginRequest handler of a web application and got the expected behavior of a single redirect.
There are other, and IMO much better, options for handling global redirect rules. On IIS7, I use the URL Rewrite module to configure rewrite rules in IIS. You can read more about it and download it here: http://www.iis.net/download/urlrewrite. The appeal of a solution such as this is that you can customize and update your rewrite rules without recompiling the application.
Edit: I was able to retrieve the raw URL without the default.aspx (after the redirect) by using instead:
Request.ServerVariables["CACHE_URL"]
It's worth a shot.
Have you looked at the IIS settings for your virtual directory? If there is a default document set to default.aspx then this will explain the infinite loop that you are experiencing. You are telling the website to redirect to the virtual directory without the "default.aspx" and IIS is detecting this on the next request and putting it back in ad infinitum.
Right click your virtual directory, select Properties and then the Documents tab. If default.aspx is in the list then that is what you will get. The Url of the request will be passed to the ASP.NET worker process as /folder/default.aspx rather than /folder/
This is not a bug. If IIS didn't do this, you would get a page not found error.
Sounds to me like you need to investigate URL rewriting: http://msdn.microsoft.com/en-us/library/ms972974.aspx

ASP.NET URL rewriting and redirecting

I am trying to wrap my head around a URL rewrtie / redirect project I need to work on. We currently have this url: http://www.example.com/Details/Detail.aspx?param1=8&param2=12345
Here is what the rewritten URL will look like: http://www.example.com/Param1/8/Param2/12345
I am using the ISAPI_Rewrite filter to allow for the "nice" url and make the page think it is still using the old url. That works fine.
Now, I need to redirect users, if they use the old URL, to the new URL. I figure I would need to use a combination of the filter and an HTTPModule / Handler to perform the redirect.
Any ideas?
Have you tried IIS URL Rewrite?
If you are not going to go down the System.Web.Routing (or use ASP.NET MVC) path then I would have a look at this link.
Using a HttpHandler would be your best bet. That way, you will be able to track all incoming requests, filter out the old format URLs and redirect them to the correct pages.

Resources