cavill
cavill

Reputation: 610

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?

Upvotes: 6

Views: 6446

Answers (2)

Arthur Papanyan
Arthur Papanyan

Reputation: 1

@if (@Model.Container == null)
{
    <span style="font-weight: bold; ">Container Not Found </span style="font-weight: bold; ">
    return;
}

Upvotes: 0

SLaks
SLaks

Reputation: 887195

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();

Upvotes: 14

Related Questions