asp.net-core-mvc

Why doesn't cookie ExpireTimeSpan setting work?

十年热恋 提交于 2020-12-06 07:00:09
问题 I used: services.AddAuthenticationCore().ConfigureApplicationCookie(o => { o.ExpireTimeSpan = TimeSpan.FromHours(1); o.SlidingExpiration = true; }); to set my authentication cookie ExpireTimeSpan in Startup.cs in ASP.NET Core MVC project. I can see that the cookie expire-time has been set correctly in the web browser after login, but it auto logout after 30 minutes every time, even if I refresh the website every 10 seconds. If I set the ExpireTimeSpan less than 30 minutes, it can timeout

How to handle dynamic error pages in .net MVC Core?

断了今生、忘了曾经 提交于 2020-12-05 04:58:27
问题 Currently I have app.UseExceptionHandler("/Home/Error"); I want to make the path relative to the original path. For example if Tenant1/PageThatThrowsError then app.UseExceptionHandler("Tenant1/Home/Error"); but if Tenant2/PageThatThrowsError then app.UseExceptionHandler("Tenant2/Home/Error"); I thought I would be able to do app.UseExceptionHandler( new ExceptionHandlerOptions { ExceptionHandler = async (ctx) => { //logic that extracts tenant ctx.Request.Path = new PathString(Invariant($"

How to handle dynamic error pages in .net MVC Core?

偶尔善良 提交于 2020-12-05 04:57:32
问题 Currently I have app.UseExceptionHandler("/Home/Error"); I want to make the path relative to the original path. For example if Tenant1/PageThatThrowsError then app.UseExceptionHandler("Tenant1/Home/Error"); but if Tenant2/PageThatThrowsError then app.UseExceptionHandler("Tenant2/Home/Error"); I thought I would be able to do app.UseExceptionHandler( new ExceptionHandlerOptions { ExceptionHandler = async (ctx) => { //logic that extracts tenant ctx.Request.Path = new PathString(Invariant($"

How to handle dynamic error pages in .net MVC Core?

送分小仙女□ 提交于 2020-12-05 04:57:06
问题 Currently I have app.UseExceptionHandler("/Home/Error"); I want to make the path relative to the original path. For example if Tenant1/PageThatThrowsError then app.UseExceptionHandler("Tenant1/Home/Error"); but if Tenant2/PageThatThrowsError then app.UseExceptionHandler("Tenant2/Home/Error"); I thought I would be able to do app.UseExceptionHandler( new ExceptionHandlerOptions { ExceptionHandler = async (ctx) => { //logic that extracts tenant ctx.Request.Path = new PathString(Invariant($"

Call a function on button click in Blazor/Razor - ASP.NET Core 3

大兔子大兔子 提交于 2020-12-04 09:03:46
问题 I just started learning ASP.NET Core and I was following the YouTube tutorial from Microsoft (https://www.youtube.com/watch?v=wA-3FA2kbpA&list=PLdo4fOcmZ0oW8nviYduHq7bmKode-p8Wy&index=11) and when I tried to call the function on button click, it does not work. The code is as follows: Button in HTML <button @onclick="(e => SelectProduct(product.Id))" data-toggle="modal" data-target="#productModal" class="btn btn-primary">More Info</button> @Code Element - Function void SelectProduct(string

Call a function on button click in Blazor/Razor - ASP.NET Core 3

こ雲淡風輕ζ 提交于 2020-12-04 09:02:42
问题 I just started learning ASP.NET Core and I was following the YouTube tutorial from Microsoft (https://www.youtube.com/watch?v=wA-3FA2kbpA&list=PLdo4fOcmZ0oW8nviYduHq7bmKode-p8Wy&index=11) and when I tried to call the function on button click, it does not work. The code is as follows: Button in HTML <button @onclick="(e => SelectProduct(product.Id))" data-toggle="modal" data-target="#productModal" class="btn btn-primary">More Info</button> @Code Element - Function void SelectProduct(string

How to add the slug to all Link generation in an asp.net core website?

时间秒杀一切 提交于 2020-12-02 08:03:18
问题 I need to be able to control the links being generated by my Url.Content("~") call to be able to accept a Slug in the beginning of the link. Basically the hosting URL will be behind a Load-balancer and may be at the root level or behind a friendlier Url... As an example: The site is configured to run under http://localhost:5001, so Url.Content("~/scripts/site.js") will generate "/scripts/site.js" this is fine if the browser is coming directly to that url or even to an alias such as www.mysite

How to add the slug to all Link generation in an asp.net core website?

安稳与你 提交于 2020-12-02 08:01:21
问题 I need to be able to control the links being generated by my Url.Content("~") call to be able to accept a Slug in the beginning of the link. Basically the hosting URL will be behind a Load-balancer and may be at the root level or behind a friendlier Url... As an example: The site is configured to run under http://localhost:5001, so Url.Content("~/scripts/site.js") will generate "/scripts/site.js" this is fine if the browser is coming directly to that url or even to an alias such as www.mysite

How to add the slug to all Link generation in an asp.net core website?

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-02 07:59:46
问题 I need to be able to control the links being generated by my Url.Content("~") call to be able to accept a Slug in the beginning of the link. Basically the hosting URL will be behind a Load-balancer and may be at the root level or behind a friendlier Url... As an example: The site is configured to run under http://localhost:5001, so Url.Content("~/scripts/site.js") will generate "/scripts/site.js" this is fine if the browser is coming directly to that url or even to an alias such as www.mysite

Routes with different controllers but same action name fails to produce wanted urls

前提是你 提交于 2020-12-02 06:03:52
问题 I am trying to set up a API for my MVC web app that will have a lot of routes but much of the same part for each one. Basically a CRUD for each area. I am also setting it up to be version-able. I have set up two controllers each with a simple action to get started and receive a conflict right off the bat. The error I get is I am after these urls https://foo.bar/aim/v1/contacts/delete/11111 https://foo.bar/aim/v1/locations/delete/11111 and so on The MVC will let you have a https://foo.bar/home