Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Response.Write() working with Razor?

Is Response.Write() working with Razor?

I tried to use @Html.RenderAction but I'm getting the error:

CS1502: The best overloaded method match for 
'Microsoft.WebPages.WebPageUltimateBase.Write(Microsoft.WebPages.Helpers.HelperResult)'   
has some invalid arguments
like image 441
stacker Avatar asked Aug 01 '10 20:08

stacker


People also ask

Why you should never use HTML raw in your Razor views?

The bad news is that using this specificity alongside Html. Raw can result in a XSS vulnerability being exploitable since an attacker can craft a special URL containing a malicious JavaScript payload that will be executed by the victim's browser if he or she sends an invalid 2FA confirmation code.

Is Cshtml a Razor?

cshtml files are razorpages or MVC views, they does not contain any C#-written client-side code. If you wan to do so, you must use JavaScript. However, a . razor file, also know as a Razor component, can have C# written in it and run on client's browser.

What are Razor expressions used for?

Razor Expression Encoding Razor provides expression encoding to avoid malicious code and security risks. In case, if user enters a malicious script as input, razor engine encode the script and render as HTML output.


1 Answers

This is the correct syntax:

@{Html.RenderAction("Index", "Menu");}

Or just using Action:

@Html.Action("Index", "Menu")
like image 167
stacker Avatar answered Oct 25 '22 13:10

stacker