locked
An HTML MVC LightSwitch Security Administration - Administration Issue RRS feed

  • Question

  • Michael Washington's excellent tutorial about getting the auth/admin off of Silverlight and into an LS HTML only project is so important for the future of a Silverlight-less LS. (Also thanks to the isWires developer(s) for their foundational contribution to this quest!).

    I'm really hungry to learn and get this part working. I downloaded the "An HTML MVC LightSwitch Security Administration" project into VS 2015 but I immediately ran into an issue with the System.Web.Optimization assembly. I tried reinstalling that assembly via NuGet but it no longer shows up as an available option. So I removed that assembly from the project and re-coded the way the scripts and css are called in the _Layout file.cshtml and everything started up and looks good. 

    And when I run the app in local debug mode, all works well and I am able to see the "Administration" link when security admin is granted for debug. But ... when I publish to the web and log in via the LS administrator user name and password, the "Administration" link never shows up.

    I mentioned the System.Web.Optimization thing because I don't know if that is the cause of the issue (I don't think it is). Michael suggested that I run it through a Fiddler session ... and I did. But I don't see any issues in the logs or reports. Could it be a setting on my web server side? But again, everything works great except for that one (most critical) thing.

    Any suggestions? Any ideas? 

    Thanks ...

    Lou


    Sunday, September 27, 2015 12:01 AM

All replies

  • After another more detailed Fiddler run, I did see a "No Proxy-Authenticate Header is present. No WWW-Authenticate Header is present" message in Fiddler's Inspector/Web Forms/Auth section. Don't know what it means but doing the research to see if this is the root of the issue(?).
    Sunday, September 27, 2015 12:44 AM
  • The fact that it works when you run it in Visual Studio is not a real test. There is code that detects when you have it running in Visual Studio and it behaves differently (this is because LightSwitch behaves differently and you have to work with the hard coded TestUser).

    I downloaded the package from my website and "System.Web.Optimization.dll" is in there so you should not have a reference problem.

    You should be able to open up my sample in Visual Studio and use the normal LightSwitch publish (https://msdn.microsoft.com/en-us/library/gg481778.aspx) Publish it exactly the way it is described in the Microsoft link. There is another publishing wizard in Visual Studio but it is NOT the LightSwitch publishing wizard and it will not work correctly.


    Unleash the Power - Get the LightSwitch HTML Client / SharePoint book

    http://LightSwitchHelpWebsite.com


    • Edited by ADefwebserver Sunday, September 27, 2015 7:45 AM
    • Proposed as answer by Angie Xu Monday, October 5, 2015 8:33 AM
    Sunday, September 27, 2015 7:45 AM
  • Thanks Michael,

    I did find and added the reference to the System.Web.Optimization.dll to a newly downloaded project. I understand that the debug mode behaves differently than the web server production mode.

    I have also been publishing as per the instructions for a LS deployment. And my hosting provider is set up for LS deployments.

    Another thing that I checked was the IIS manager side. I enabled "Forms Authentication" via the IIS manager to see if that was the issue. But unfortunately, that didn't change anything (it still does not show me the Administration link when I log in as the LS administrator).

    Thanks for your help and suggestions but this seems to be a blocker for me.


    PapaLouG


    • Edited by PapaLouG Sunday, September 27, 2015 10:51 PM
    Sunday, September 27, 2015 10:50 PM
  • Ok the only other thing I can think of is that the code will look in the web.config to see what the administrator name and password is and create that user if it does not exist. If when you publish you don't select and fill in the create a administrator option it wont put that user in the web.config so the code in the MVC project wont run.

    Putting an administrator in the web.config should fix the problem.


    Unleash the Power - Get the LightSwitch HTML Client / SharePoint book

    http://LightSwitchHelpWebsite.com

    Monday, September 28, 2015 1:29 AM
  • Hi Michael,

    unfortunately one of my applications is written in VB :(

    I believe it's not possible to do a direct translate?

    Regards

    Sven


    Sven Elm

    Monday, September 28, 2015 7:55 AM
  • Hi Michael,

    unfortunately one of my applications is written in VB :(

    I believe it's not possible to do a direct translate?

    Regards

    Sven


    Sven Elm


    It can be translated to VB from C# but I don't have a translation, sorry.

    Unleash the Power - Get the LightSwitch HTML Client / SharePoint book

    http://LightSwitchHelpWebsite.com

    Monday, September 28, 2015 12:00 PM
  • Thanks again Michael,

    I've put an admin in web.config but still no success. As you know, the root of the issue is that, for some reason, the deployed app is returning null when I log in as an administrator for Microsoft.LightSwitch.Security:SecurityAdministration.FirstOrDefault() in index.cshtml because it is not hitting the <li><a href="Admin">Administration</a></li> line:

        @if (Request.IsAuthenticated)
        {
            <p>
                <ul>
                    @if (Model.Where(x => x.Name == "Microsoft.LightSwitch.Security:SecurityAdministration").FirstOrDefault() != null)
                    {
                    <li><a href="Admin">Administration</a></li>
                    }
                    <li><a href="HTMLClient">LightSwitch Application</a></li>
                </ul>
            </p>
        }

    What would cause this to be null? Not easy to debug since I'm not really able to see everything due to the way LS handles admin log ins as testuser in debug mode.


    PapaLouG

    Thursday, October 1, 2015 4:59 PM
  • Make sure you have set security in the Properties of your app and you have one called "SecurityAdministration"


    Unleash the Power - Get the LightSwitch HTML Client / SharePoint book

    http://LightSwitchHelpWebsite.com



    • Edited by ADefwebserver Friday, October 2, 2015 3:43 PM
    • Proposed as answer by Angie Xu Monday, October 5, 2015 8:33 AM
    Thursday, October 1, 2015 7:53 PM
  • Hi Michael,

    Sorry for the delay reply (I've been working on several other projects). I did not tamper with the SecurityAdministration entry as I understand that is the core admin requirement for LS. So I have made sure that entry was always included without change ... but still same issue.

    I am working in VS2015 professional and hosting on Arvixe (all other parts of my LS projects work well - it's just the admin stuff that doesn't seem to stick).


    PapaLouG

    Monday, October 5, 2015 8:06 PM
  • Hi Michael,

    Sorry for the delay reply (I've been working on several other projects). I did not tamper with the SecurityAdministration entry as I understand that is the core admin requirement for LS. So I have made sure that entry was always included without change ... but still same issue.

    I am working in VS2015 professional and hosting on Arvixe (all other parts of my LS projects work well - it's just the admin stuff that doesn't seem to stick).


    PapaLouG


    Darn, sorry I am at a loss :(

    Unleash the Power - Get the LightSwitch HTML Client / SharePoint book

    http://LightSwitchHelpWebsite.com

    Monday, October 5, 2015 8:25 PM