jQuery Mobile showing incorrect URL - c#

On a MVC3 project I'm working on whenever I do a redirect to action on the controller the URL that is shown in the browser is the original request. Not the redirected one. Has anyone seen this or know of a workaround for it?
So for example. I can click a link with a href that equals...
http://www.test.com/account/LogOut
Which on the controller will redirect to the homepage, but once I'm logged out and the homepage is shown...the url still shows http://www.test.com/account/LogOut
This is causing some quirky behavior with a couple of other things that I've got going on.

You should use the attribute 'data-ajax="false"' in your logout link.

Related

I need to redirect the /default page of my application(Sitecore) to another page of my hosted site

1.I have tried adding the IIS Rewrite Rule which works for local environment but not in the higher environments.
2.Sitecore redirect settings is also not working.
3.Currently (localhost)/default loads the homepage and I need this to get redirected to another page of my site.
Can somebody help me to achieve this without overriding the HttpBeginRequest Processor?
public IActionResult Privacy(){return Redirect("https://google.com"); }
As you have an MVC project, requests will all route to a controller action, you can set the redirection in the corresponding action.

Response.redirect showing the previous page url in the address bar

I used Response.Redirect in my code and it works fine but the url is not correct.It always shows the previous page url.
Here is my code.
Response.Redirect("Main.aspx?DocAddEdit=customer incident");
Please suggest.
I even tried server.transfer, but same thing happened.
I find it highly unlikely that the url is the same. According to the MSDN documentation on Response.Redirect
ASP.NET performs the redirection by returning a 302 HTTP status code.
That means the browser actually performs the redirect and requests the new url.
Server.Transfer, on the other hand, will render and return the url you specify, in which case the url in the user's browser will stay the same.
Are you sure you tried Response.Redirect and not just Server.Transfer?
Recently I came across the same issue with the previous URL remains after Response.Redirect and
I could solve it using Response.End() after the line Response.Redirect().

site will not redirect to custome page and throw 404 error in asp.net site

I don't know this question is already asked or not. But i am stuck in one problem.
I have one CMS application in that some page are static and some are dynamic.
When i access url using http://abc.com/abc.aspx
Now in this case if abc.aspx is cms page then it will redirect me to that page but if it is not cms page then this will redirect me to the my custom page http://abc.com/page-not-found.aspx
Now my question is that if i write only http://abc.com/abc then it will didn't redirect me to the http://abc.com/page-not-found.aspx but it will throw me the error 404 page or directory not found.
Now I have to check two things
1) if any custome page is not there then it will display http://abc.com/page-not-found.aspx
2) when http://abc.com/page then it will also redirect me to http://abc.com/page-not-found.aspx
Please help me our from this. This will work fine in my local but only problem in live environment.
Thanks in advance.
Regards
AB Vyas
You may need to look into Handlers in your web.config .
http://msdn.microsoft.com/en-us/library/46c5ddfy(v=vs.100).aspx

Routing in Asp.Net 4.0

I have successfully setup routing in Asp.Net 4.0 webforms. I have set up:
routeCollection.MapPageRoute("Default Page", "Default/{ProductName}/{CategoryName}", "~/Default.aspx");
However, problem is even though the user browses to default.aspx, the page still shows up. How can I avoid this? I want only the MapPageRoute to work. I want that when user browses to default.aspx some error should be thrown or 404 page should be shown etc. In short I do not the user to browse through default.aspx. How can I do this?
Thanks in advance :)
you can handle this issue through two ways.
In global.asax in Request_Start event check that if the requested url end by .aspx redirect to error page.
Use Url rewriter, by regular expression identify the wrong requests and redirect them to custom error page.
Never used routing in WebForms myself, but have you tried looking at the Request.Url? If that ends with/contains you could handle this by redirecting to an error page.

Transfer instead of redirect to login in forms authentication

I give to google a sitemap with all my pages, when the crawler tries to access them he gets redirected to the login page.
In the login page I write an explanation of what the page does so the crawler can see that each page is different.
The problem now is that the bot is clever enough as to recognize that it is a redirect:
URLs not followed
When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL.
HTTP Error: 302
If instead of using a redirect in RedirectToLoginPage(String), Microsoft had used a Server.Transfer, google would never find out it is actually the same page.
Any Ideas?
As Carl said, if access to your content requires a log in, then there isn't a whole lot you can do.
However, if you can separate out a "teaser" of each content page and have a link to "read more" from those pages that requires a login, then you'll be good to go.
The teaser page should have enough searchable text that google will be able to successfully include it in search results.
There are a number of sites that do just this. You search for something, click on the link to go to their site. Once there you can see maybe two paragraphs worth of information. If you want more a link takes you to a login / register page.
Okey I found a not elegant solution, but it suits my needs:
http://forums.asp.net/t/1358997.aspx
""For now, I found a workaround: I capture the End-request event and see if the status code is "302 redirected"; if it is, I'll just alter the address from there and do whatever I need to do. Not the most elegant solution (and requires more processing for every page request; not just login redirects), but at least it works.""

Categories