Getting 302 response code in widget ajax call - c#

I am working on a MVC application in which when have an option to request password reset email. When we got the email with the link, that link will redirect to the welcome page where we will enter Password and Confirm password and then we will click continue. Once all the validations of Welcome page passed, the user will be redirected to Dashboard page where we are loading few widgets through ajax calls. In one of our production environment these ajax calls are giving 302 http code instead of 200. Due to this behavior the widgets are loading either welcome page or login page as their content instead of original content. From the code base, no where we are redirecting to Welcome page or login page from any of the widget ajax calls. As this is happening in only production environment but not in local, it became hard to debug.
Can anyone please help guide me on how to figure out the cause of redirection.
Thanks....

Related

Blazor page to MVC page

I try to logout in code in a procedure on a Blazorpage.
var url = $"{navigationManager.BaseUri}Identity/Account/Logout";
navigationManager.NavigateTo(url);
That doesn't work. I got the message
Sorry, there's nothing at this address.
Odd, because the address directly in the addressbar of the browser, brings me to the logout page.
What do I miss that blazor does not seem to find the logout
Force a reload with the second parameter your not using.
navigationManager.NavigateTo(url,true);

ASP.NET MVC - ref is null when user goes from youtube.com

I develop an ASP.NET MVC application and I need to get url of youtube page, from user goes to my page. For example, on youtube.com under my video I put a link to my web-site. When user goes to my website I should receive link to youtube page. I try to receive this link using the next code:
Request.UrlReferrer
but when I go to my page from youtube.com the Request.UrlReferrer is null.
Also, note, that I click on my link on youtube.com page I go to my page thru page like:
https://www.youtube.com/redirect?q=http%3A%2F%2mysite.azurewebsites.net%2FHome%2FFillForm%3FFormID%3DbdHN7K9oFkQ&redir_token=tl-svjka0c6n2TVko3CXXXoDak18MTM5NzMyODMwMUAxMzk3MjQxOTAx
How can I get UrlReferrer value?
This is most likely caused by the fact that it's redirecting from an https URL to an http URL and the browser gets paranoid about security.
That said, the referer header is not guaranteed to be sent in any case and your logic can't depend on it being available.

Response.Redirect that does POST instead of GET

I am looking for a method that will forward my form post. I have an outside source posting me SAML, I need them to POST to my defualt page to create a cookie before I can redirect them to the page they can operate on. The issue I am having is when I redirect them to the page they can work on the form variables (post data) is lost. I can see in fiddler I am receiving their SAML in the WebForms, but when I response.redirect to the next page, the form data is gone. I understand this is because response.redirect does a get, I was wondering if someone knew of another method, or solution to this problem. Thanks in advance.
Client Posts Saml To My default page -> my default page redirects to a shopping page (because the shopping page creates a non-user cookie) -> the shopping page then redirects to a results page (the results are based off of what is in the saml). Short: I need to preserve the initial SAML posted to me across multiple pages so I can process it on my results page. I would like to continually post it to each intermediate page.
Write a POST form to the page, fill in the data, and also write some JS code that triggers a submit. For example ADFS does this with SAML tokens.

Why is ServerVariables["HTTP_REFERER"] skipping a page?

Here is my situation:
Page1.aspx redirects to Page2.aspx which does some processing (does not display to the user) and then redirects to Page3.aspx which checks the ServerVariables["HTTP_REFERER"] or Request.UrlReferrer.
I understand that the referring information can sometimes be blank and can't be entirely relied upon; however the ServerVariables["HTTP_REFERER"] or Request.UrlReferrer on Page3.aspx is showing Page1.aspx instead of Page2.aspx which I would have expected.
Does the referring information only get set if the page displays to the user?
Redirecting is done using Response.Redirect in order to change the URL in the address bar of the browser.
because the http redirect instructs the browser to find the page in a new place, so the browser assumes it's still dealing with the original request on page1.aspx, and hence sends that through as the referer :)
it's worth bearing in mind that the referer is just sent through from the browser and hence cannot be trusted 100% - some proxies remove it altogether for example.
I believe part of it depends on how the page is being redirected: Server.Transfer or Response.Redirect.
http://haacked.com/archive/2004/10/06/responseredirectverseservertransfer.aspx

Asp.Net page reload problem after login

I am devolping a web application.the problem is that i am using a login control (not a .NET control) which is a part of master page and is acessible from all pages. if user log In from a page the login control updates itself and displlay some statistics of logged In user but the specific page does not reload. (some options on page are visible only to authenticated users, so that after login, page should be reloaded to display such options)
after logIn methoed I wrote
Reponse.Redirect(Request.Url.AbsoluteUri)
after this the browser response the "Page cannot be displayed"
It would be of great help to me.
Many Thanks, Regards. AZHAR
From you description it is not clear what happens, but with high possibility you get infinite loop, when page is redirected to itself again and again.
Most obvious problem that you place redirect code in Page_Load,
as possible resolution:
Place Reponse.Redirect(Request.Url.AbsoluteUri) to OnLogin event of your login control
if you anyway want use Page_Load, at least add following check:
if(IsPostBack)
Reponse.Redirect(Request.Url.AbsoluteUri)
But last case is very bad style because may have lot of side effects.
Make sure your redirect is not causing a loop. Check Page.IsPostBack
Be aware that POST variables are lost during this operation.
Another thing that you should look at is the roles that you allow in the folder (in the web.config file in the folder).
I accidentally misspelt a role name and it kept redirecting my users to the login page.

Categories

Resources