Can anyone tell how to write you own method and call it view or simply write "Hello world" in the following manner? This is what I tried to write on my
Index.cshtml:
<h1>
Hello,
<span>
@{ HttpContext.Current.Response.Write("World!"); }
</span>
</h1>
but it is not working? Thanks for any help :)
Response.Write
is use for write string content to the responce,If you want to bind your test to the view than you can create a model for the view and initialize from controller and pass it to the view see below example,
Here my model is type of
string
, you can create your complax model if thare are more than one propertyController:
View: