Developer forum

Forum » Templates » Razor redirect in frontend only

Razor redirect in frontend only

Nuno Aguiar
Reply

Hi,

 

Creating a template for the login feature, we set up a redirect in Razor.

System.Web.HttpContext.Current.Response.Redirect("/Default.aspx?Id=000");

 

The problem is that the backend is triggering it when we save the page. How can we adapt/change it so this only happens in the frontend?

 

Nuno


Replies

 
Morten Bengtson
Reply
This post has been marked as an answer

if(Dynamicweb.ExecutingContext.IsFrontEnd())
{
    // redirect    
}

Votes for this answer: 1
 
Morten Bengtson
Reply

if(Dynamicweb.ExecutingContext.IsFrontEnd())
{
    // redirect    
}

 
Nuno Aguiar
Reply

Hi Morten,

 

That did the trick. Thanks a lot

 

Nuno

 

You must be logged in to post in the forum