Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of End / Response.End in razor?

I'm trying to stop the rest of a page loading based on some parameters; but am not sure of the correct syntax.

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

The above throws this error: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

Any ideas?

like image 875
cavill Avatar asked Feb 24 '11 22:02

cavill


1 Answers

Your code tries to print Response.End to the page.

You can just write (in your code block)

return;

to stop running the generated Execute() method.

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

Response.End();
like image 140
SLaks Avatar answered Sep 28 '22 07:09

SLaks