Link to home
Start Free TrialLog in
Avatar of Patrick Chapman
Patrick Chapman

asked on

Why site doesn't work the same in VS 2017 as it did in VS2010

I am having problems with an old Visual Studio 2010 Webforms site that uses forms authentication and works well when published to production server.  The problem is now I have moved up to Visual Studio 2017 and having an issue of casting WindowsIndentity object to another custom class.  It used to work in 2010 but does not work in 2017 when debugging.  Tried to change the code and now the problem is that when starting to debug the site, some browsers are not prompting for a login and using NTLM and I need it to force forms authentication.  I have it set to forms in the web.config file.  Some day we will rewrite the site but stuck with old system for now.  

Why would something that worked in VS 2010 not work the same in VS 2017?   Site is ASP.NET 4.0.


Thanks
Patrick
Avatar of Peter Hutchison
Peter Hutchison
Flag of United Kingdom of Great Britain and Northern Ireland image

Normally Forms Authentication is configured by IIS and stored in the web.config with your web application.
e.g.
            <authentication mode="Forms">
                  <forms loginUrl="Login.aspx" name="adAuthCookie" timeout="60" path="\">
                  </forms>
            </authentication>

What are you using as the source of authentication, LDAP eg. AD DS domain, SQL DB or cloud service?

See
https://support.microsoft.com/en-us/help/301240/how-to-implement-forms-based-authentication-in-your-asp-net-applicatio 
https://docs.microsoft.com/en-us/dotnet/api/system.web.security.formsauthenticationticket?view=netframework-4.7.2
Avatar of Patrick Chapman
Patrick Chapman

ASKER

I am familiar with that. Why can't I run in forms authentication in debug mode?  Seems to be ntlm.
Windows Authentication is what it uses for Forms access.  Browser should popup a login window and person logs in and code makes a cookie from the login information plus add some Userdata.
You said the issue is when you're trying to cast to a custom object.  Are you talking just one project for the website or multiple?

Also is this a web project (eg: compiled to a DLL) or website (compile on demand)?


If you comment out the cast do you get the correct results?  EG: I'm trying to isolate whether it's the cast / custom object that's the issue or visual studios itself?


Also from: https://stackoverflow.com/questions/24194941/windows-authentication-not-working-in-iis-express-debugging-with-visual-studio

check the applicationhost.config
Thanks for the reply.

Only one project for the website.  It seems to be a website not a compiled single DLL.  I can edit pages and just copy to server without recompiling the site and have to copy the BIN folder again.

I cannot copy out the cast because the next couple lines usually need objects from that custom class object.  I have gotten around most of it by casting differently but strange how the production site is still working without these changes and if running in VS 2010 no problems but in VS2017 these casting and session lost issues occur.

Thanks
Patrick
Can we see some code?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Chapman
Patrick Chapman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial