0

My Web Application on our corporate intranet utilizes windows authentication. If this application is accessed via the Safari, the safari browser does not support windows authentication.

I do not have a sign/login page for this application but seems like I will have to create one if the application is accessed via Safari browser. I can create the authentication page, I need to understand, How I could detect that the user is a safari user and route to a view which would enable the user to add their network credentials to authenticate.

Thanks in advance.

tereško
  • 58,060
  • 25
  • 98
  • 150
tam tam
  • 1,870
  • 2
  • 21
  • 46

2 Answers2

1

You can use the display modes feature, and create a display mode that works only for iPad. To detect the iPad, use this technique. Create a custom mobile display mode using this technique, where you inherit from DefaultDisplayMode and supply the ContextCondition.

I did this for the Opera Mobile emulator, and all you have to do is tweak it to check for the iPad (in the first link).

public class OperaMobiDisplayMode : DefaultDisplayMode
{
    public OperaMobiDisplayMode()
        : base("Mobile")
    {
        ContextCondition = (context => IsMobile(context.GetOverriddenUserAgent()));
    }
}
Community
  • 1
  • 1
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
1

You can redirect according to the user-agent that its being using. You can use a route constrain to do it.

For example you should create a custom constraint that check for the user agent. To create a route constraint you need to create a class that implement IRouteConstraint

public class UserAgentConstraint : IRouteConstraint 
{ 
   private string _userAgent; 
   public UserAgentConstraint(string userAgentParam) 
   { 
       _userAgent= userAgentParam; 
   } 

   public bool Match(HttpContextBase httpContext, Route route, string parameterName, 
                     RouteValueDictionary values, RouteDirection routeDirection) 
   { 
       return httpContext.Request.UserAgent != null && 
                          httpContext.Request.UserAgent.Contains(_userAgent); 
   } 
}

and then apply this constraint to the route you need it and send the request to the controller/action you wont, for example:

public static void RegisterRoutes(RouteCollection routes) 
{ 
    routes.MapRoute("MyRoute", "{controller}/{action}", 
        new { controller = "Home", action = "LoginForIPad",
              httpMethod = new UserAgentConstraint("iPad")}); 
}
Diego
  • 666
  • 1
  • 8
  • 27