My application allows me to redirect to Account / LogOn? ReturnUrl =% 2f

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

The following is the error message. After updating the page, the application works fine. If I do not get access to the application after a while, the error will return. Any ideas?

Server error in application "/".

Resource is not found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could be deleted if their name was changed or Temporarily unavailable. Look at the following URL and make sure it is spelled correctly.

Requested URL: / Account / LogOn

+4
source share
5 answers

The solution was to disable forms authentication in IIS.

+2
source

This is pretty common. For resource style sheets, etc. This is usually the result of not using @ Content.Url. I assume that for other problems you can hardcode your links, rather than using @ Url.Action. This is again a common occurrence, I have encountered it several times.

Indeed, basically in the development environment you are not actually interested in virtual directories, however in the production environment this is more of a problem.

I would think that / Account / Login points to the root directory when using IIS IIS, which you want to point to this route through the virtual directory. If the link is created through something like <% = Html.ActionLink%>, then you're fine. But if you have javascript and you call the url, or if your hardcoding your links to MyController / MyList, then it will not find it.

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

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

Let me know if that makes sense.

+3
source

Perhaps you see this because your web.config file has the wrong resolving role = "RoleNameHere"

If you configured your webconfig page for roles as shown below, make sure that the role matches what you specified for the login role. For example, you can write Administrators instead of the correct Administrator . After correctly recording the role, ReturnUrl leaves, and you can again access the page after logging in.

 <location path="AdminDepartments.aspx"> <system.web> <authorization> <allow roles="Administrator"/> <deny users="*"/> </authorization> </system.web> </location> 
+2
source

Like ek_ny, this is a very common problem. You must create these two variables globally for your application.

In the code behind, put this in a class that can be accessed from all pages:

 Public String SiteRootPath = (New Control).ResolveUrl("~/"); 

At the front end, enter the homepage file:

 var jvSiteRootPath="<%=SiteRootPath %>"; 

Now you can use this for all URLs that need to be referenced from the root path.

+1
source

I think you should enable Anonymous Authentication your site along with Forms Authentication .

Select your application on IIS , then in authentication mode select authentication.

0
source

All Articles