Angular ui router – Redirection doesn’t work at all

What we would need here, is to do NOT redirect, if the state TO is already the ‘login’. Just a drafted adjustment would be $rootScope.$on( ‘$stateChangeStart’, function(e, toState , toParams , fromState, fromParams) { var isLogin = toState.name === “login”; if(isLogin){ return; // no need to redirect anymore } … And also, we should call … Read more

ASP.net MVC support for URL’s with hyphens

C# version of John’s Post for anyone who would prefer it: C# and VB version on my blog public class HyphenatedRouteHandler : MvcRouteHandler{ protected override IHttpHandler GetHttpHandler(RequestContext requestContext) { requestContext.RouteData.Values[“controller”] = requestContext.RouteData.Values[“controller”].ToString().Replace(“-“, “_”); requestContext.RouteData.Values[“action”] = requestContext.RouteData.Values[“action”].ToString().Replace(“-“, “_”); return base.GetHttpHandler(requestContext); } } …and the new route: routes.Add( new Route(“{controller}/{action}/{id}”, new RouteValueDictionary( new { controller = “Default”, … Read more

How to change route to username after logged in?

You need to add a route to cover the case that has a user name. public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.MapRoute( name: “Username_Default”, url: “{username}/{controller}/{action}/{id}”, defaults: new { controller = “Home”, action = “Index”, id = UrlParameter.Optional }, constraints: new { username = new OwinUsernameConstraint() } ); routes.MapRoute( name: “Default”, url: “{controller}/{action}/{id}”, defaults: … Read more

Discovering Generic Controllers in ASP.NET Core

What happens by default During the controller discovery process, your open generic Controller<T> class will be among the candidate types. But the default implementation of the IApplicationFeatureProvider<ControllerFeature> interface, DefaultControllerTypeProvider, will eliminate your Controller<T> because it rules out any class with open generic parameters. Why overriding IsController() doesn’t work Replacing the default implementation of the IApplicationFeatureProvider<ControllerFeature> … Read more