Response.Redirect() will not redirect on Internet Explorer - c#-2.0

I am using
Response.Redirect("someurl",true);
in the page_preInit event to redirect all the requests that come to a page. It works fine on Firexox, but if i access the page from internet explorer 7/8, it says page can not be found and will not redirect to new URL.
Any idea why this happens??
Update:
I tried giving a radom URL in the redirect such as google.com and it works fine. Actually the URL I am trying to redirect is not accessible on my machine, it is on another VPN. I guess IE will not change the URL on the addressbar if it can not access the URL. Firefox on the other hand changes the address on the address bar.

Is your Response.Redirect contained within a try/catch block? This can cause issues with Redirection.

As i mentioned on the Update, IE wont change the URL if it returns 404. Since i had no access to the URL i am redirecting, it was returning a 404. But firefox behaves differently.

I also had a similar issue where Internet Explorer would not redirect using a standard Response.Redirect call. I also saw the same issue on certain Android devices on WIFI, but who worked correctly on cell service. Very strange.
The problem is with Microsoft's legacy redirect method in .NET. Certain network routers and older browsers handle the response codes differently. Here's the change to C# code that fixed it:
OLD CODE:
HttpContext.Current.Response.Redirect("www.mysite.com", true);
NEW CODE:
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Redirect;
WebOperationContext.Current.OutgoingResponse.Headers.Add("Location", "www.mysite.com");

Related

Why does Firefox automatically add "%25/" to my URI?

In a Confluence page there is a link to an external html page like "blah.net/project/latest/index.html". When I work with IE or with Chrome everything is ok. But when clicking this link in Firefox the result is "blah.net/%25/project/latest/index.html".
It seems that this is not a Confluence problem. I entered the url directly into the address field of the browser: the incorrect uri with the "%25/" occurs as well.
Does anybody know what happens and how to avoid it?
Best regards

Safari ignoring/removing anchors (or "hashtags") when clicking hyperlinks?

I need to point one page to another and then scroll to a particular section. In Chrome and Firefox, using an URL like www.example.com#section1 does the trick. (#section1 can be an anchor or an element's id).
However, in Safari, the hash disappears when I click the link.
Why is this happening? Is it possible to do it on Safari? If not, how can I get around this problem?
When using hyperlinks that point to inside sections on other pages you must remember to add a slash (/) before the hashtag for cross browser compatibility.
Eg: www.example.com/#item-1
doing www.example.com#item-1 isn't accepted by all browsers (apparently by Chrome and Firefox it is)
Case: I have parameters after '#' like url#myParam=123, when I changed params like
url#myParam=789 Safari sometimes loaded previous page based on myParam=123,
although in Address bar it showed myParam=789
Solution : Use url?#myParam=123, then Safari will everytime load new page.
Using '?' before '#' solved my problem.
I had a related problem with Safari (on iPhone/iOS) seemingly stripping off the hash/fragment when doing a:
var newHash = ...;
window.location.replace("#" + newHash);
The actually problem was a javascript error that only appeared on Safari. Since I could not easily assess a javascript console for the iPhone, I chose to download an old version of Window's Safari (related post, download).
Then, I could replicate the problem from the iPhone on my Window's desktop using the old version of Safari. At that point, I found a javascript tag had a missing ']'. This was a legitimate bug, but it was somehow ignored by Chrome, Firefox, and IE.
The window.location.replace() was not even being called, because the code was breaking out on the javascript error. So the problem wasn't that Safari was stripping the hashtag, even though it appeared that way from multi-browser testing.
I just experienced an issue like this. I was using a URL re-write in the asp.net web.config. With Safari, the hash and everything after was removed. After trying some of the things mentioned above I was still having problems. The issue for me was that this was all happening under HTTPS. Once I specified the full URL in the redirect and included the https:// scheme the redirect worked correctly and preserved the hash. Note this wasn't an issue with Chrome or Firefox.
For me it was the exact same issue like mrbinky3000 has stated above: The server mod-rewrite was killing the hash in safari.
The solution was to use a full absolute link like:
http://www.example.com/path/#item-1

Connection Reset on long urls ($_GET) WAMP

I have an application under Yii, and I have this problem regarding my urls.
With the Yii CGridView, when we filter, the application passes an ajax GET request to the server in a form of a very long url. example:
http://site.com/reports/default/index/MEmailrequestsList%5Bid%5D//MEmailrequestsList%5Bname%5D//MEmailrequestsList%5Bperson%5D//MEmailrequestsList%5Bemail%5D//MEmailrequestsList%5Bcreated%5D//MEmailrequestsList%5Busersender%5D/josalie/MEmailrequestsList%5Bstatus%5D//MEmailrequestsList_page/2/ajax/reportsgrid?ajax=reportsgrid
With Firefox or Chrome's firebug, it doenst show any errors, just a failed status. Upon reviewing, it gives off a status of connection reset.
I am running the application in Windows, under WAMP.
With other urls (non yii) (
http://site.com/samplepage/?id=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1&poads=2&asd=1...
)
I think I did it.
I managed to fix the issue by making the URL of the paginations to use the default get parameter url symbols (? and &). I did this by placing a 'appendParams'=>FALSE to the UrlManager of the application.
It is fixed now and hopefully somebody will find this helpful.

X-Frame-Options ALLOW-FROM a specific site allows from all

I'm using a rails application to serve a page from abc.com. In it, I set the response headers in my application controller (for every request through before_filter) so that it can be accessed through an iframe only from a specific site (xyz.com), through the following code:
def set_x_frame_options
response.headers["X-Frame-Options"] = "ALLOW-FROM http://www.xyz.com"
end
The problem is, not only am I able to access the page from abc.com on xyz but also on any other website. I want to limit the access to only xyz.com. When I examine the response headers in chrome console I can see the X-Frame-Options is being passed on correctly. This is happening across all browsers. Am I missing something?
For those looking for a definitive answer: it's not implemented in webkit, but does work in Firefox reportedly as of version 18.0. The following ruby syntax works for me in Firefox 20.0 on OSX:
response.headers["X-Frame-Options"] = "Allow-From http://www.website.com"

Session_Start() called, then Session_End(), then Session_Start() again and URL changes

I've got a weird one. :-) I have an MVC (ASP.Net C#) app that uses CBA (and WIF) for authentication.
It works fine when I go to the default root of my app: https://myapp This calls my IP (https://myappSTS) takes credentials and all is good.
The issue happens when I try to go to a non-root url before login. Like this:
1. Open browser
2. Enter a non-default URL like https://myapp/customerpage
In this scenario, in the global.asax, I see I hit Session_start and when I check the httprequest url it is correct ("/customerpage"). Then my Session_End() gets called. Then Session_Start() gets called again! This time my URL is the root url ("/") and it all works great.
This sequence happens before STS is called. STS does not get called until the second session is created.
The problem is that we sometimes email links to customers and they should just click, login and get taken to the right place.
Does anyone know why this is happening?
I'm running IIS7.5 (64 bit), .Net 4.
Thanks!
Rich
http://richdotnet.blogspot.com/

Resources