Unable to set field values when deployed to server

Unable to set field values when deployed to server

Old forum URL: forums.lhotka.net/forums/t/11881.aspx


TNRollingStone posted on Thursday, March 14, 2013

I have an ASP.NET MVC 3/4 application that is using CSLA for a portion of our business logic.  The permissions to read/write are handled through AD by a domain account, the same account as the Application Pool Identity and .NET Impersonation user.  When testing on my local machine, the validation runs perfectly.  Once the application is deployed to one of our test environments (dev or qa) I receive exceptions that seem to point to permissions.  I've verified that the username being used by the assembly is indeed the correct user, but have been unable to set the values of any of the fields due to not having the appropriate permissions.  Anyone experienced anything like this before?

RockfordLhotka replied on Thursday, March 14, 2013

Are you reloading the correct principal/identity object into memory on each callback to the web server? This would normally be done with a bit of code in global.asax.cs, and is discussed in the 'Using CSLA 4' ebook series as well as previous CSLA books.

TNRollingStone replied on Thursday, March 14, 2013

This is my first journey into CSLA and was told that I should be able to just use the DLL from our company's framework (referencing CSLA as well).  I was unaware of having to reload the correct principal/identity, but will read into that and get back to you.  Thank you for the quick response!

TNRollingStone replied on Thursday, March 14, 2013

I went through the sections of your C# 2008 and CSLA 4 ASP.NET MVC books, but am not having any luck at all.   During my debugging, I noticed that each call to the AcquireRequestState function is returned after checking the authentication type as "Windows".    

The site is an MVC 4 application with sub-applications hosted as Areas within the main app, in case that has any relevance to my situation.

 I am  I added the following lines of code to the application:

 

Web.config

<add key="CslaAuthentication" value="Windows"/>

 

Global.asax.cs

  protected void Application_AcquireRequestState(object sender, EventArgs e)

        {

            if (HttpContext.Current.Handler is IRequiresSessionState)

            {

                if (Csla.ApplicationContext.AuthenticationType == "Windows")

                    return;

 

                System.Security.Principal.IPrincipal principal;

                try

                {

                    principal = (System.Security.Principal.IPrincipal)HttpContext.Current.Session["CslaPrincipal"];

                }

                catch

                {

                    principal = null;

                }

                if (principal == null)

                {

                    if (User.Identity.IsAuthenticated && User.Identity is FormsIdentity)

                    {

                        FormsAuthentication.SignOut();

                        Response.Redirect(Request.Url.PathAndQuery);

                    }

                    else

                    {

 

                    }

                }

                else

                {

                    Csla.ApplicationContext.User = principal;

                }

            }

        }

 

Copyright (c) Marimer LLC