2

Hy,

I'm trying to redirect users which has deactivated javascript with following code in the main layout (_Layout.cshtml):

<noscript>
    <meta http-equiv="refresh" content="0;url=/Error/NoJavascript" />
</noscript>

Rather it works, but it refreshes every time. How can I redirect only once instead of every time?

I've found this code sample, but it doesn't let me compile (error message: can't implicite convert from void to object) I use this code sample in my view (_Layout.cshtml):

@Response.Redirect("/Error/NoJavascript")

Thanks for help :)

1 Answer 1

3

Use a simple static HTML file for this special case which has not this meta data:

<meta http-equiv="refresh" content="0;[email protected]("~/Content/NoScript.html")" />

Your returned view from the Error/NoJavascript action method has a reference to the layout page automatically or just set its layout to null.

@{
    Layout = null;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for help .. the layout solution is great for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.