I am moving the functionality from standart ASP.Net forms web site to ASP MVC 4 web site. The problem is I can't set ClientTarget property of the page.
<div>Current version contains the lines: if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1) Page.ClientTarget = "uplevel";</div> <div> </div> <div>I investigated in Google and found out it is a common solution for browser detection problem. But seems in ASP MVC version (in controller, in view, in filters) I don't have such property Page.ClientTarget.</div> <div></div> <div>Please,
advice and help. Thanks.</div>
I don't know why it is done so and my aim is just to carry existing functionality to MVC, but http://browsercompatibility.codeplex.com/ gives explanation of asp menu control (of course I will not use
this control in MVC site). I guess the bigger problem is descibed herehttp://blog.lavablast.com/post/2011/05/29/Gotcha-iPad-versus-ASPNET.aspx. (an
application that worked fine when you shut down your iPad minutes ago will be completely unusable. No amount of refreshing will solve the issue. Clearing Safari’s cache and using it outside of the home screen icon is the only workaround).
Well, I think you're going to run into a lot of things like this if your mindset is to port from WebForms to MVC. They're really two different programming models. It's really going to be a re-write and not a port since so many features are different and
don't map from one model to the other.
My point is that there's nothing like it in MVC. Setting this in the Page sets the ClientTarget property of the HttpRequest (which nulls out the Browser property). The next time you access the Browser property it then re-creates the HttpBrowserCapabilities
based upon the setting you pass.Basically all this is internal to the System.Web DLL.
To achieve the same net result, you'd have to assign the Browser property of the underlying HttpContext.Current.Request object (there's no set on the HttpRequestBase).
programmersh...
0 Points
4 Posts
ClientTarget property
Aug 07, 2012 09:04 PM|LINK
I am moving the functionality from standart ASP.Net forms web site to ASP MVC 4 web site. The problem is I can't set ClientTarget property of the page.
<div>Current version contains the lines: if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1) Page.ClientTarget = "uplevel";</div> <div></div> <div>I investigated in Google and found out it is a common solution for browser detection problem. But seems in ASP MVC version (in controller, in view, in filters) I don't have such property Page.ClientTarget.</div> <div></div> <div>Please, advice and help. Thanks.</div>
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: ClientTarget property
Aug 07, 2012 09:07 PM|LINK
What are you trying to do? IOW, does Request.Browser not give you what you need?
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
programmersh...
0 Points
4 Posts
Re: ClientTarget property
Aug 07, 2012 09:18 PM|LINK
I don't know why it is done so and my aim is just to carry existing functionality to MVC, but http://browsercompatibility.codeplex.com/ gives explanation of asp menu control (of course I will not use this control in MVC site). I guess the bigger problem is descibed here http://blog.lavablast.com/post/2011/05/29/Gotcha-iPad-versus-ASPNET.aspx. (an application that worked fine when you shut down your iPad minutes ago will be completely unusable. No amount of refreshing will solve the issue. Clearing Safari’s cache and using it outside of the home screen icon is the only workaround).
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: ClientTarget property
Aug 07, 2012 09:36 PM|LINK
Well, I think you're going to run into a lot of things like this if your mindset is to port from WebForms to MVC. They're really two different programming models. It's really going to be a re-write and not a port since so many features are different and don't map from one model to the other.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
programmersh...
0 Points
4 Posts
Re: ClientTarget property
Aug 07, 2012 09:58 PM|LINK
Yes, models are really different but actually my problem is only how to do Page.ClientTarget = "uplevel". Any ideas?
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: ClientTarget property
Aug 07, 2012 10:06 PM|LINK
My point is that there's nothing like it in MVC. Setting this in the Page sets the ClientTarget property of the HttpRequest (which nulls out the Browser property). The next time you access the Browser property it then re-creates the HttpBrowserCapabilities based upon the setting you pass.Basically all this is internal to the System.Web DLL.
To achieve the same net result, you'd have to assign the Browser property of the underlying HttpContext.Current.Request object (there's no set on the HttpRequestBase).
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
programmersh...
0 Points
4 Posts
Re: ClientTarget property
Aug 08, 2012 06:08 AM|LINK
Can anybody gives me more precise source code or other ideas?