Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove authentication from an MVC project?

Tags:

c#

asp.net-mvc

I'm learning MVC from the internet, using Visual Studio 2013.

After finishing my project and deploying it to a host via "publish", it worked perfectly (locally too).

Though now, the app throws an authentication form on login (after publishing). locally it doesn't do that. I want to remove authintication totally, since the site (with all its pages) is open.

I'm sorry for the dull question, but I searched and cannot find a clue about my problem precisely, probably due to utter ignorance in that side of the framework..please help.

I tried to manually trace things, I have an "startup.cs" which contains :

 public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

        }
    }

This directs me to the file "Startup.Auth" which automatically has :

public void ConfigureAuth(IAppBuilder app)
        {

            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
...

When trying to remove the function call in Startup.cs , the project immediately throws a very basic login menu.

Then, In my project's settings, I kept both "windows authentication" and "anonymous authentication" DISABLED. Kept the function call in "Startup.cs" too.

But in that scenario it throws "this page has a redirect loop"..

Please help me, I'm very confused about this : I want to totally remove authentication.

like image 982
Mohammed Baashar Avatar asked Apr 10 '15 12:04

Mohammed Baashar


People also ask

How do I change the authentication in MVC project?

Select File >> New >> select ASP.NET Core Web Application, and change the authentication to Windows Authentication. We can also configure the existing application for Windows Authentication by selecting the option of WA. To configure the authentication manually, open Visual Studio project properties >> go to Debug tab.

How do I turn off Windows Authentication in web config?

Expand the computer name, then Sites, then Default Web Site, then click on the name of the desired site. Select Authentication. Set Windows Authentication to Disabled and set Basic Authentication to Enabled.


1 Answers

You should just enable anonymous authentication in IIS settings for your website.

Additionally, if you are using AuthorizeAttribute, you can mark your controllers/actions which should be accessed anonymously with AllowAnonymousAttribute. Anonymous authentication still should be enabled in IIS. If you are using AuthorizeAttribute and are not able to remove it or mark actions with AllowAnonymous, you should manually create some mock user identity. But this is a question for another discussion.

To avoid redirection to the login page, you should set authentication mode to "None" in your web.config

like image 104
THTP Avatar answered Sep 23 '22 04:09

THTP