How To Upgrade Web Application to OWIN

This article describes steps necessary to upgrade the web application to the new version, which is based on OWIN since version 2015.4. Upgrade is done only once, it is not necessary to perform such operation with each release.

Step-by-step guide

  1. Make sure .NET framework in version 4.5.1 or higher is installed.

  2. Make sure ASP.NET MVC 4 is installed. Installation package is available at http://www.microsoft.com/en-us/download/details.aspx?id=30683.

  3. Download an OWIN based release of the web application.

  4. Deploy the files from the downloaded package.

  5. There is an upgrade/upgrade_2015.4.0.cmd script in the downloaded package. Execute it directly from upgrade directory, It will clear the obsolete files.

  6. Open web.config and make the following changes:

    Add new keys to <appSettings> tag

    <add key="webPages:Version" value="2.0.0.0"/>
    <add key="autoFormsAuthentication" value="false"/>
    <add key="enableSimpleMembership" value="false"/>
    

    Comment or remove <authentication> tag

    <!--<authentication mode="Forms">
        <forms name="asapAuthCookie" timeout="10" />
    </authentication>//-->
    

    Authentication cookie settings (including session expire timeout) are now possible to change using Startup.cs User Management Configuration.

    Enable access to /Login and /Recover urls

    <location path="Login">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
    </location>
    <location path="Recover">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
    </location>
    

    Add handlers

    <add verb="*" path="Gateway.aspx" type="Origam.Server.Handlers.GatewayHandler, Origam.Server.Handlers" name="GatewayHandler"/>
    <add verb="*" path="SignOut.ashx" type="Origam.Server.Handlers.SignOutHandler, Origam.Server.Handlers" name="SignOutHandler"/>
    <add verb="*" path="ReportProblem.ashx" type="Origam.Server.Handlers.ReportProblemHandler, Origam.Server.Handlers" name="ReportProblemHandler"/>
    <add verb="*" path="GeoLocation.ashx" type="Origam.Server.Handlers.GeoLocationHandler, Origam.Server.Handlers" name="GeoLocationHandler"/>
    

    Set default document as Portal.cshtml

    <defaultDocument>
        <files>
            <clear/>
            <add value="Portal.cshtml"/>
        </files>
    </defaultDocument>
    
  7. Configure OWIN container through Startup.cs file. Its location is expected in App_Code folder of the application. Sample file is provided with the package as Startup.cs_. Sample file contains configuration for cookie authorization via Asp.Net Membership provider.

  8. Switch the application to the application pool based on .NET 4.0.

  9. Make sure you have a record in the BusinessPartner table with UserName="``guest".

If your application was configured to use Asp.Net Membership provider, your work is done and you should be able to log in to the system.

If your application is using AJAX login and sign out functionality, you need to update URLs. They’re changed from /AjaxLogin.ashx and /AjaxSignOut.ashx to /AjaxLogin and /AjaxSignOut.

Related Articles

Comments:

@washi Why is there a default document in web.config if we need to set it up also in Startup.cs?

Posted by admin at Apr 15, 2015 17:37

Because web.config configures IIS, while Startup.cs configures OWIN.

Posted by washi at Sep 29, 2015 13:54

But only one of them is actually used, isn't it? Which one takes precedence, OWIN or IIS?

Posted by admin at Sep 29, 2015 14:37