Equivalent to End / Response.End in a razor?

I am trying to stop the rest of the page loading in some ways; but I'm not sure about the correct syntax.

@if(dayRes + dayTri == 2){<text>Sorry, etc</text> @Response.End} 

The above error: CS1502: Best overloaded method matching for "System.Web.WebPages.WebPageExecutingBase.Write (System.Web.WebPages.HelperResult)" contains some invalid arguments

Any ideas?

+6
razor webmatrix
source share
1 answer

Your code is trying to print Response.End on the page.

You can simply write (in your code block)

 return; 

to stop the execution of the generated Execute () method.

You can also call End as a method inside your code block:

 Response.End(); 
+13
source share

All Articles