asp.net-core-2.0

How to detect postback in Razor Page?

烈酒焚心 提交于 2019-12-24 20:13:11
问题 I'm using a single razor page (cshtml) that has a form and @functions{} section to capture an OnPost() . All of that works fine. In the HTML section, I need to know when a post back has occurred and display a message. I'm not sure where or how that is done in a Razor Page. I've tried IsPost but that isn't available. I created a string property in the class and set a value on it in OnPost but once I'm in the view, the property is null . I assigned a value into ViewData["mystring"] but it is

C# Creating global number which increase by 1

╄→尐↘猪︶ㄣ 提交于 2019-12-24 19:53:04
问题 I am writing simple bank account tutorial program. For each new customer which enrolls, the account number will be incremented by 1, for a new id. I saw example in "C# Mueller" book. I am just curious if this is proper way to conduct this, how will it handle concurrency enrollments? Is there a better to handle this, maybe with Singletons or global variables, memory cache? How would item like this be handled in real world application? public class BankAccount { private static int

How to force re authentication between ASP Net Core 2.0 MVC web app and Azure AD

瘦欲@ 提交于 2019-12-24 19:41:18
问题 I have an ASP.Net Core MVC web application which uses Azure AD for authentication. I have just received a new requirement to force user to reauthenticate before entering some sensitive information (the button to enter this new information calls a controller action that initialises a new view model and returns a partial view into a bootstrap modal). I have followed this article which provides a great guide for achieving this very requirement. I had to make some tweaks to get it to work with

Aspnetboilerplate: Configure login path for redirect on core mvc template

不打扰是莪最后的温柔 提交于 2019-12-24 19:12:43
问题 Sorry if this is straightforward, but I'm having a real block with this one. I'm trying to move all the standard views and controllers from aspnetboilerplate's Module Zero (Core + MVC + jQuery) into a new area (Admin) and want to make sure the redirect for login on unauthorized view goes to /Admin/Login as opposed to /Account/Login, which is the default. Any help really appreciated. Dale Update Here is the ConfigureServices method: public IServiceProvider ConfigureServices(IServiceCollection

AspNet.Security.OAuth.Extensions Error while introspection

北战南征 提交于 2019-12-24 19:08:06
问题 I'am writing a test application with asp.net core 2.0, AspNet.Security.OpenIdConnect.Server and AspNet.Security.OAuth.Extensions. I ran into a problem with introspection of the access token. When I get my token from /connect/token and send it to my resource server I get the following errors in my server: fail: AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerHandler[0] The introspection request was rejected with the following error: invalid_request ; (null) info: AspNet.Security

Using dash/hyphen in Razor Page filename - does compile but VS shows errors

喜你入骨 提交于 2019-12-24 18:25:09
问题 There seems to be an issue with the Razor Pages (2.1.0-preview1-007211) and IntelliSense in Visual Studio 2017 (15.4.0 preview 2.0) with the filenames containing dashes. In order to reproduce: Create a new razor page e.g. razorpagetest.cshtml In the code add @{ ViewData["Title"] = "Test123"; } Save and close the file Rename razorpagetest.cshtml to razor-pagetest.cshtml Save and close the file Reopen the file and you will see errors on the errors list (although it builds OK) Has anyone

How to Integrate CCAvenue with .Net Core API and angular 5 app?

血红的双手。 提交于 2019-12-24 17:07:55
问题 I am developing an angular website with ASP.Net Core 2.0 for web API. I want to integrate CCAvenue payment gateway. Can you provide any reference? I searched for it on the internet but didn't find anything useful 来源: https://stackoverflow.com/questions/51263653/how-to-integrate-ccavenue-with-net-core-api-and-angular-5-app

ASP.NET Core 2.0 - Http Response Caching Middleware - Nothing cached

穿精又带淫゛_ 提交于 2019-12-24 16:49:22
问题 I created a new solution from WebApi .Net Core 2.0 template in Visual Studio. I added the following in startup. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddHttpCacheHeaders(opt => opt.MaxAge = 600); services.AddResponseCaching(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseResponseCaching(); app.UseHttpCacheHeaders(); app.UseMvc(); } Then, with

Serilog not getting application events, only coded logger events

送分小仙女□ 提交于 2019-12-24 16:37:25
问题 I set up my application to use Serilog as the logging mechanism. And I do in fact get log files and can view them on Seq. Initially I was getting the application events logged, but for some reason I am no longer getting them. See the images below. In the first image I am getting application events. Later, when doing the same testing operations, I am NOT getting the application events any more, only the coded events in the files (i.e. _logger.LogWarning("Warning"); ) I set up Serilog in Main

Modifying MS Graph responses for display on site

做~自己de王妃 提交于 2019-12-24 12:16:41
问题 I have a c# Web App that connects to Azure AD B2C directory with MS Graph to display user data. I'm looking for a best practice way to display the contents returned by Graph Query. I could always do straight forward string formatting, but I'm looking for something more optimal. I use HttpResponseMessage httpmsg = await QueryGraphAsync("/users?$select=displayName"); and the response looks like this : {"@odata.context":"https://graph.microsoft.com/beta/$metadata#users(displayName)","value":[{