-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Razor Pages #494
Comments
@DamianEdwards |
@DamianEdwards as cyrusel pointed out it might be good to have a full beginner training path. For js, php, classic asp devs, who want to jump into core without mvc. It would be nice if the training vision was to star on razorpages, then add more advanced and eventually learn MVC. I see how this would be useful for both evangelists, and the comunnity. Versus just having a different framework |
Will this not be less secure and also my concern is it will make page rendering slow ?? Can anyone help me |
Why would it be less secure? |
@iamzm the security is the same as the rest of ASP.NET Core. If you have any specific concerns, please let us know! If you think you've found a security bug, please contact [email protected] with a detailed bug report. The performance in general should be roughly the same as ASP.NET Core MVC, because Razor Pages is built on ASP.NET Core MVC. If you have observed performance issues, please log a bug in this repo and we will investigate. Thanks! |
@eliton There is something wrong related to microsoft.dotnetcore.mvc.taghelpers! if you remove it from _viewstart and submit the form with Post method, request validation token won't be generated and you will get bad request (error 400). In fact either unti-forgery should not be relied on tagHelpers or there should be a way to disable unti-forgery. |
@cyrusel if you remove the Tag Helpers registration then the anti-forgery token will not be rendered with the form, hence the failure on POST as the page expects a token by default. You can disable anti-forgery but it's not recommended. |
@DamianEdwards |
This will turn off autiforgery token validation for pages. You can also still generate an antiforgery token the old fashioned way using |
@Eilon Thanks for making things clear. Regarding slowness i meant if we are going to write our business logic in Page itself .. Don't you think it can be improper pipeline ? Can you please explain a little |
@DamianEdwards What if i have to write non-CRUD method ?? Like you guys are suggesting On- ?? |
@DamianEdwards What if i want to redirectto("www.facbook.com") ? any possible way here ? |
@iamzm If you want to redirect to another site, you can use public void OnPost()
{
Response.Redirect("http://www.facebook.com");
} or public RedirectResult OnPost()
{
return Redirect("http://www.facebook.com");
} There is no reason for putting business logic inline. You place it in the page controller or in a separate layer which is called in the page controller. If you do put your business logic inline, your application is unlikely to experience any slowness in running. It may take longer to compile the page on first run, and it is likely to make it more difficult to maintain in the longer run if it's a true business app, and not just a simple blog. You can structure your Razor Pages application in exactly the same way as an MVC application, except that you have one controller per view in Razor Pages instead of one controller per feature or business area in MVC. Most of the rest of Razor Pages is the same ASP.NET Core as MVC. |
Thanks @mikebrind what if i want to write non-crud action in Page ? Like instead of OnPost, OnGet, OnDelete .. Is it possible i can write my custom method like verifyemail ? So can i follow like OnVerifyEmail ?? |
You can add any method to your page. This is how you might do it: @{
@functions{
public void OnPost(string email)
{
if(VerifyEmail(email))
{
Response.Redirect("http://www.facebook.com");
}
}
public bool VerifyEmail(string email)
{
return Regex.IsMatch(email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
}
}
} |
@mikebrind Thanks for helping me out ! I had also same idea but wanted to be sure |
Is there any discussion anywhere about some mechanism to embed RazorPages without running a Web application? Essentially using razor as a stream/string templating engine inside of a another application that is not a Web app or even just a sub-system that doesn't know about a Web app? |
@RickStrahl Libraries are must i think to include to get RazorPages work even in another outside application |
We have our own usage of Razor like this here. This is what powers the developer exception page and the like. There's a sample using Razor + someof MVC to generate templated emails here. If there's something in particular that we need to improve for this usage of Razor, please open issues. |
Locking this ancient issue because we've implemented it!. If you have something to talk about please open a new issue instead of posting on this one, thanks! |
We will support a simple model where a user can crate a CSHTML page that can handle requests but still use the primitives of MVC.
| 57 | 10153 | Reported By: Yishai Galatzer |
The text was updated successfully, but these errors were encountered: