xilin-silence / dropthings

Automatically exported from code.google.com/p/dropthings
0 stars 0 forks source link

Error in authentication only in IIS - solution needed. #158

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Omar - I hope you can help me resolve the below issue.

What steps will reproduce the problem?
I am changing Dropthings to allow Windows Authentication as per another users 
suggested post here. 

I have changed the default.aspx Page_Load to look like this:

protected void Page_Load(object sender, EventArgs e)
    { //added for windows authentication

        //var response = new UserSetup();
        string pageTitle = (Request.Url.Query ?? Resources.SharedResources.NewTabTitle).TrimStart('?');
        if (!Membership.ValidateUser(Profile.UserName, "Password"))
        {
            bool activationRequired = ConstantHelper.ActivationRequired;

            RegisterUserResponse registerUserResponse = null;
            var facade = Services.Get<Facade>();
            {
//suggested by Omar in another post
                facade.FirstVisitHomeTab(Profile.UserName, pageTitle, Profile.IsAnonymous, true);
                registerUserResponse = facade.RegisterUser(Profile.UserName, "Password", Profile.UserName, activationRequired);
            }
        }
    }

I have also added the following to the web.config:
<!--added to change to windows authentication-->
    <authentication mode="Windows"></authentication>

I am getting an error when I load the website vis IIS on my local computer:
http://computername/dashboard/Default.aspx

What is the expected output? What do you see instead?
I was hoping to see the DOMAIN/USERNAME in the label, but I am getting the 
following error on Line 71 in Facade.User.cs.

Sequence contains no elements 
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information about 
the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Sequence contains no 
elements

Source Error: 

Line 69:                 // No setting saved before. Create default setting
Line 70: 
Line 71:                 userSetting = this.userSettingRepository.Insert(new 
UserSetting
Line 72:                     {
Line 73:                         AspNetUser = new AspNetUser { UserId = 
userGuid },

Source File: 
C:\Inetpub\wwwroot\Dropthings-2.6.5-src\src\Dropthings.Business.Facade\Facade.Us
er.cs    Line: 71 

Stack Trace: 

[InvalidOperationException: Sequence contains no elements]
   System.Linq.Enumerable.First(IEnumerable`1 source) +257
   Dropthings.Business.Facade.Facade.GetUserSetting(Guid userGuid) in C:\Inetpub\wwwroot\Dropthings-2.6.5-src\src\Dropthings.Business.Facade\Facade.User.cs:71
   Dropthings.Business.Facade.<>c__DisplayClass1.<FirstVisitHomeTab>b__0() in C:\Inetpub\wwwroot\Dropthings-2.6.5-src\src\Dropthings.Business.Facade\Facade.Visit.cs:84
   OmarALZabir.AspectF.AspectF.Return(Func`1 work) in D:\work\RND\AspectF\AspectF_Src\AspectF\AspectF.cs:98
   Dropthings.Business.Facade.Facade.FirstVisitHomeTab(String userName, String pageTitle, Boolean isAnonymous, Boolean isFirstVisitAfterLogin) in C:\Inetpub\wwwroot\Dropthings-2.6.5-src\src\Dropthings.Business.Facade\Facade.Visit.cs:25
   _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Dropthings-2.6.5-src\src\Dropthings\Default.aspx.cs:198
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

What version of the product are you using? On what operating system?
Windows xp
VS2008

Please provide any additional information below.

When I run the solution from VS2008 I DO NOT get this error and when I step 
into the code, Line 71 of Facade.User.cs is not executed.  It only seems to be 
executed when I browse via IIS.

Thanks for any help.

Original issue reported on code.google.com by steran...@gmail.com on 19 Nov 2010 at 11:20

GoogleCodeExporter commented 8 years ago

Original comment by omaralzabir@gmail.com on 19 Apr 2011 at 6:38