razor-pages

How to configure an ASP.NET Core multi microservice application and Azure AKS ingress routes so that it doesn't break resources in the wwwroot folder

帅比萌擦擦* 提交于 2019-12-07 18:43:56
问题 I have two ASP.NET Core apps. One is a Headless CMS (API), and the other one is a Razor Pages blog front-end (with a REST client that communicates with the Headless CMS/API). I then have an Azure AKS cluster. In it I have an ingress resource with the following routes (as per the instructions from the following AKS docs: https://docs.microsoft.com/en-us/azure/aks/ingress-tls#create-an-ingress-route ). Each route is mapped to each of the apps/services mentioned above: spec: rules: - host:

Global Error Catcher

戏子无情 提交于 2019-12-07 02:46:31
问题 In my project I want to log all the errors happen in the application in a database table. I catch almost all errors using try catch blocks, but I cannot catch the global errors like 4xx and 5xx. There are cases that the application does not redirect to the Exception Handler defined in the Configure method of the Startup.cs like when I type a url which does not exist. app.UseExceptionHandler("/Error"); Is there a way to catch all the unhandled errors occurred in my application? 回答1: You could

How to configure an ASP.NET Core multi microservice application and Azure AKS ingress routes so that it doesn't break resources in the wwwroot folder

巧了我就是萌 提交于 2019-12-06 09:17:05
I have two ASP.NET Core apps. One is a Headless CMS (API), and the other one is a Razor Pages blog front-end (with a REST client that communicates with the Headless CMS/API). I then have an Azure AKS cluster. In it I have an ingress resource with the following routes (as per the instructions from the following AKS docs: https://docs.microsoft.com/en-us/azure/aks/ingress-tls#create-an-ingress-route ). Each route is mapped to each of the apps/services mentioned above: spec: rules: - host: mydomain.westeurope.cloudapp.azure.com http: paths: - backend: serviceName: headless-cms-svc servicePort: 80

Change Bound Property in OnPost in model is invalid

放肆的年华 提交于 2019-12-06 07:24:50
I am using ASP.NET Core Razor Pages and I want to add a counter for a number of attempts it takes a user complete a task. I am using: [BindProperty] public int Attempts { get; set; } And inside the OnPost I am doing this: public IActionResult OnPost() { if(!IsCorrect()) { Attempts++; return Page(); } return RedirectToPage($"./Index") } I expected this to update the data on the client side, since without [BindProperty] & return Page() , data would be lost if the model was invalid. However, Attempts never increases on the client. I think I may have misunderstood how this works? Any suggestions?

How to dynamically load pages from plugins in Razor Pages application?

Deadly 提交于 2019-12-06 05:29:06
问题 I'm trying to deal with plugins using Razor Pages application. Solution consists of 3 projects: one Razor Pages application and two Razor Class Libraries (RCL). Application must not refer RCL projects statically, they must be loaded as plugins: There's nothing special inside pages. Feature pages just produce simple HTML. Index page builds a sort of menu. Index page model: public class IndexModel : PageModel { public IEnumerable<MenuItem> MenuItems { get; private set; } public void OnGet() {

How to create shared form in ASP.NET CORE Razor Pages?

浪子不回头ぞ 提交于 2019-12-06 05:00:38
问题 I have to create a reusable form in my page header. It should be displayed on each page. Simple input and submit button that will send a POST request. Options that I'm aware of are partial views or view components. I checked a documentation about view components but there is no mention that it works with forms. Only InvokeAsync method is available to initialize a view. With partial view, it may be hard to define its page model and I don't understand where to put its POST handler. One other

Global Error Catcher

那年仲夏 提交于 2019-12-05 07:45:35
In my project I want to log all the errors happen in the application in a database table. I catch almost all errors using try catch blocks, but I cannot catch the global errors like 4xx and 5xx. There are cases that the application does not redirect to the Exception Handler defined in the Configure method of the Startup.cs like when I type a url which does not exist. app.UseExceptionHandler("/Error"); Is there a way to catch all the unhandled errors occurred in my application? You could create your own Exception filter, which implements IExceptionFilter e.g.: public class GlobalExceptionFilter

using partial view on asp.net core razor pages

牧云@^-^@ 提交于 2019-12-04 17:42:32
I am developing a project that runs on asp.net core 2 razor pages. I need a solution to load a partial view or component to in a RAZOR pages and also I could send come object (some class model or basic string). this is detail pages which I want load partial view into. Using this code : @{ await Html.RenderPartialAsync("Shared/Partial/DeleteModal", Model.DeleteModalModel); } this is my partial view inside <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header bg-red"> <h4 class="modal

SignInManager.PasswordSignInAsync() succeeds, but User.Identity.IsAuthenticated is false

故事扮演 提交于 2019-12-04 16:14:02
I'm new to ASP.Net Core and trying to create an user authentication system. I'm using ASP.Net Core Identity user management. I have the below code for logging in an user. /Areas/Identity/Pages/Account/Login.cshtml.cs public async Task<IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input

Asp.net core razor pages load partial page

北城以北 提交于 2019-12-04 15:33:51
I use asp.net core 2 new feature Razor pages. in the _layout.cshtml. <body> <div> @await Html.PartialAsync("_LayoutHeader") <div class="row"> <div> <div class="row"> @RenderBody() </div> </div> </div> the _layoutHeader.cshtml is page with code behind. @page @using Microsoft.AspNetCore.Identity @model Yiko.Ent.WebRazorPages.Pages._LayoutHeaderModel and @RenderBody will load index.cshtml with pagemodel. @page @model Yiko.Ent.WebRazorPages.Pages.Home.IndexModel @{ ViewData["Title"] = "Home"; } run the project. throw a error: InvalidOperationException: The model item passed into the