How to redirect if javascript is disabled in mvc masterpage

How to redirect if javascript is disabled in mvc masterpage

I have a masterpage on which i want to check if user have disabled its javascript then redirect to a simple error.aspx page mvc integration test


Filtering a List view in an ASP.MVC application
On Masterpage just add this code.
setting displayname data annotation dynamically in mvc
<noscript> <% Response.Redirect(Url.Action("ActionName","ControllerName")); %> </noscript> 
If user disabled the javascript it will redirect to specific controller action..
ASP.NET MVC - TextArea values

What's the difference between a Web Server and a Game Server?

C#: Caching w/ method attributes VS manually using System.Web.Caching


Blank LogOn view in MVC application
The usual way to approach this problem is to redirect a user who has javascript enabled and display the error for the user who has it disabled using the noscript tag..
return a list of string as JSONResult
 <script type="text/javascript">      location.href = 'pagethatneedsjavascript.aspx';  </script>  <noscript>      This page needs JavaScript enabled!  </noscript> 
Alternatively if your page isn't the first page the user would load in the current session, you could add a link to the page like.
<a href="/linktopage.aspx?js=disabled" onclick="location.href='/linktopage.aspx?js=enabled';return false;">the page</a> 
If the user has javascript disabled, they'll go to the page referenced in the href attribute, if they have it enabled the JavaScript in the onclick attribute will be executed instead.

. You can then on the server side read the querystring variable and redirect if it equals "disabled".
if ( Request.QueryString["js"] == "disabled" ) {     Response.Redirect("error.aspx"); } 
Note that if the page is bookmarkable the user might end up on the page using js=enabled without js actually being enabled..

67 out of 100 based on 32 user ratings 807 reviews