MVC Razor @foreach

What is the best practice on where the logic for the @foreach should be at? Nowhere, just get rid of it. You could use editor or display templates. So for example: could perfectly fine be replaced by a display template: and then you will define the corresponding display template (if you don’t like the default … Read more

What does HTML.Raw do?

Text output will generally be HTML encoded. Using Html.Raw allows you to output text containing html elements to the client, and have them still be rendered as such. Should be used with caution, as it exposes you to cross site scripting vulnerabilities.

HTTP Error 500.19 and error code : 0x80070021

Got precisely the same error and came to this question. As @SpaceBison mentioned in comments, this answer describes the solution – https://stackoverflow.com/a/12867753/404099. I spotted it too late and it misses some steps. This is what worked for me: Windows Server 2012, IIS 8.5. Should work for other versions too. Go to server manager, click add roles … Read more

What is the use of @Html.AntiForgeryToken()?

This is a security feature to help protect your application against cross-site request forgery. Example: Let’s assume you have a register functionality in your web app. You have an AccountController (example.com/account/register) where you expect people to submit their info. Normally before someone posts the registration information needs to visit the actual (example.com/account/register) than submit the form. Let … Read more