Pergunta

My machine needed to get rebuilt. So I figured I upgrade to VS 2013, cause 2012 had always been buggy interface for me compared to 2010.

My Project was designed on the old FormsAuthentication. I do NOT want to change this. I have too much work to do on this project to learn and to take time to change it.

My project was working just fine before the system crash and upgrading to VS 2013.

My project is no longer working, it has a loop direct because of the authorizing of a login person.

Is it possible to have FormsAuthentication in a 2013 project. I keep searching and everyone advocating to go with the new way. But I do not desire to do that right now.

Here is the alpha code right now that i been working with. No, I haven't specified specific pages yet for rights, I know this.

But all this was working in a rough form before my machine crashed and a rebuild and upgrade to 2013.

Debugging it makes it through all the code and creates and sets the formauthentication cookie just fine in the method below. No errors.

It is being created, I can see the file in the IE directory but the site is not recognizing it. And it goes back to the login page again to force a log on.

Is there a change I need to know about to get it to be backwards compatible? Or is this just not doable with VS2013?

<authentication mode="Forms">
  <forms name="pclogin" loginUrl="~/login.aspx" defaultUrl="~/login.aspx" slidingExpiration="true" timeout="200" enableCrossAppRedirects="true"/>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>


    protected void SetAuthentication()
    {
        string RightData = "";
        //select only the pages and the menu items.  These are the only rights we are concerned with for .net authentication.  
        //other rights will be checked through HasRight method
        IEnumerable<DataRow> rows = from r in Rights.AsEnumerable()
                                    where r.Field<int>("RightType") == 1 && r.Field<int>("RightType") == 0
                                    select r;

        foreach (DataRow dr in rows)
        {
            RightData = RightData + dr["RightId"].ToString() + ",";
        }

        //New ticket for authentication
        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddYears(1), true, RightData, FormsAuthentication.FormsCookiePath);

        //Encrypt the cookie for going over the internet
        string Encrypt = FormsAuthentication.Encrypt(ticket);
        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, Encrypt);
        cookie.Expires = DateTime.Now.AddYears(1);

        //Add the cookie to the header respone to the browser
        HttpContext.Current.Response.Cookies.Add(cookie);
    }

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top