如何复制ASP.NET MVC项目并使其不接受来自原始应用程序的身份验证cookie? [英] How to duplicate an ASP.NET MVC project and make it not accept authentication cookies from the original application?

查看:63
本文介绍了如何复制ASP.NET MVC项目并使其不接受来自原始应用程序的身份验证cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我复制了一个ASP.NET MVC项目,并将所有名称空间重命名为新的项目名称.
但是现在,如果我登录到原始应用程序,并立即导航到重复的应用程序,则欺骗应用程序将接受身份验证Cookie并允许我通过.它们托管在同一域中.
这些应用程序使用ASP.NET Identity进行身份验证.

I duplicated an ASP.NET MVC project and renamed all the namespaces to the new project name.
But now, if I log into the original application, and immediately navigate to the duplicated application, the dupe application accepts the authentication cookie and allows me through. They are hosted on the same domain.
The applications use ASP.NET Identity for authentication.

在重复的应用程序中是否需要更改唯一的应用程序密钥或类似的密钥,以使其不接受来自原始密钥的身份验证cookie?

Is there a unique application key or something like that that needs to be changed in the duplicated application so that it does not accept authentication cookies from the original?

推荐答案

在任一应用程序中更改CookieName,它将为您提供帮助.您可以在以下位置找到CookieName:

Change CookieName in your either application, it will help you. You can find CookieName in:

ASP.NET身份更改现有行的值或在Startup.Auth.cs

ASP.NET Identity Change the value of the existing line or add a line to within Startup.Auth.cs

public partial class Startup
{
    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),

            /* Add the following line */
            CookieName = "MyAppUniqueCookieNameHere" 

        });
    }
 }

以防表单身份验证

<configuration>
   <system.web>
      <sessionState cookieName="MyAppUniqueCookieNameHere" />
   </system.web>
</configuration>

希望它会对您有所帮助!:)

Hope it will help you! :)

这篇关于如何复制ASP.NET MVC项目并使其不接受来自原始应用程序的身份验证cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆