Login to the MVC 5 ASP.NET template Web Application fails when moved from the root folder -


i used asp.net web application template create new "single page application" "authentication: individual user accounts". run default settings without problem.

if don't deploy application root folder of web server authentication fails. culprit in app.viewmodel.js file following code can found:

self.addviewmodel = function (options) {     var viewitem = new options.factory(self, datamodel),         navigator;      // add view appviewmodel.views enum (for example, app.views.home).     self.views[options.name] = viewitem;      // add binding member appviewmodel (for example, app.home);     self[options.bindingmembername] = ko.computed(function () {         if (!datamodel.getaccesstoken()) {             // following code looks fragment in url access token             // used call protected web api resource             var fragment = common.getfragment();              if (fragment.access_token) {                 // returning access token, restore old hash, or @ least hide token                 window.location.hash = fragment.state || '';                 datamodel.setaccesstoken(fragment.access_token);             } else {                 // no token - bounce authorize endpoint in accountcontroller sign in or register                 window.location = "/account/authorize?client_id=web&response_type=token&state=" + encodeuricomponent(window.location.hash);             }         }          return self.views[options.name];     }); 

the line window.location = "/account..." redirects browser url offset @ root directory. unfortunately hard coding new folder instead (which avoid anyway) not solve problem entirely.

the redirect seems work @ first behind scenes in accountcontroller.csfile authorize()is called in turn calls authenticationmanager.signin(identity) , somehere there magic going on. there redirect http://localhost/foo/account/login?returnurl=... , we're started.

i missing obvious. i'd appreciate pointers.

it's easy replicate. create new web app default settings , go project properties , change "project url" http://localhost:49725/foo moves app new folder called "foo".

i'm facing same problem, change did was:

  1. in file app.viewmodel.js added new parameter (returnurl):

    // no token - bounce authorize endpoint in accountcontroller sign in or register window.location = "/account/authorize?client_id=web&response_type=token&state="      + encodeuricomponent(window.location.hash)      + "&returnurl=" + encodeuricomponent(window.location); 
  2. in method validateclientredirecturi of class applicationoauthprovider read parameter , set return url:

    public override task validateclientredirecturi(oauthvalidateclientredirecturicontext context) {     if (context.clientid == _publicclientid)     {         uri expectedrooturi;         if (!string.isnullorempty(context.request.query["returnurl"]))         {             expectedrooturi = new uri(context.request.query["returnurl"]);         }         else         {             expectedrooturi = new uri(context.request.uri, "/");         }          if (expectedrooturi.absoluteuri == context.redirecturi)         {             context.validated();         }         else if (context.clientid == "web")         {             var expecteduri = new uri(context.request.query["returnurl"]);             context.validated(expecteduri.absoluteuri);         }     }      return task.fromresult<object>(null); } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -