Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My app keeps me redirecting to Account/LogOn?ReturnUrl=%2f

I created an MCV 3 app and deployed it to a development server in my organization. It works OK in my development machine. However, I noticed that in the dev server, the application redirects me to Account/LogOn?ReturnUrl=%2f web page even after I've logged in correctly. I also see that sometimes some of the assets(CSS, Javascript, images) are not served either.

The error message shown is below. After refreshing the page, the application works just fine. If I don't accesss the app in a little while, the error comes back. Any ideas?

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Account/LogOn

like image 364
Carlos Blanco Avatar asked Feb 23 '23 09:02

Carlos Blanco


1 Answers

This is fairly common. For resources style sheets, etc, it's usually a result of not using @Content.Url. My guess is that for the other issues, you might be hardcoding your links instead of using @Url.Action. Again this is common, I have ran into it a bunch of times.

Really basically in development environment you're not really concerned with virtual directories-- however in production environment it's more of an issue.

I would think that /Account/Login points to root directory when using IIS IIS, you want to point to to this route via the virtual directory. If the link is generated through something like <%=Html.ActionLink %>, then you're fine. But if you have some javascript and you're calling a URL, or if your hardcoding your links to /MyController/MyList then it won't find it.

Same with css files. If you look at how the Site.css file is accessed when creating a new project, then you'll see something like this:

<link href='<%=Url.Content("~/Content.Site.css")%>' etc.. etc..

Let me know if this makes sense.

like image 56
ek_ny Avatar answered Mar 08 '23 06:03

ek_ny