Click here to Skip to main content
15,797,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 1 mvc application and that is running fine on 2 url's with the same code deployed to different folder for both the url's to work.

URL's are like - web form authentication - windows authentication

Now the requirement is we have 2 deploy the code in one folder only and both the url's should work like earlier when we are deploying in 2 folders for same application.

so now we have to create a folder named AD within the MVC application and call home controller from root directory after windows authentication.

Any help will be appreciated

What I have tried:

I've tried creating a folder named AD within the application and used windows authentication but when I put my credentials and trying to redirect on root folder's home controller then getting error that resource not found. and sometimes there is no route configured.

also I've tried creating a *.aspx page and redirecting from there
this.Response.RedirectToRoute("~/Home/Index"); but noting works.
Updated 5-Aug-21 2:58am

1 solution

You'll need a Windows Authentication action on your Home controller:
public ActionResult WindowsLogin(string returnUrl = null)
    FormsAuthentication.SetAuthCookie(User.Identity.Name, false);
    if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl)) return Redirect(returnUrl);
    return RedirectToAction(nameof(Index));
Then update your web.config file to turn on Windows authentication for that route:
<location path="AD">
                <windowsAuthentication enabled="true" />
                <basicAuthentication enabled="true" />
                <anonymousAuthentication enabled="false" />
You may need to "unlock" these sections:

If you're using IIS, open IIS Manager, open the "Feature Delegation" page from the Management group. Find the four "Authentication - ..." sections, and ensure that they are set to "Read/Write".

If you're using IIS Express, you'll need to edit the applicationHost.config file, which is located in the hidden ".vs\Project_Name\config" folder within your solution folder.
Share this answer
Ashutoshkrsingh 9-Aug-21 15:21pm    
I've tried this but getting below error
HTTP Error 500.22 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

and if I change pipeline mode to classic then the actual is not working
Richard Deeming 10-Aug-21 2:53am    
Don't change it to "classic" pipeline; find the setting it's complaining about and fix that instead.

If you open the page in a browser running on the server itself, you should get a detailed error message which will tell you which setting it doesn't like.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900