asp.net-core-mvc

ASP.Net Core MVC/API/SignalR - Change authentication schemes (Cookie & JWT)

陌路散爱 提交于 2019-12-11 02:28:31
问题 I've a .Net Core 2.2 web application MVC in which I've added API controllers and SignalR hubs. On the other side, I've a mobile app that calls the hub methods. Before calling hubs from the app, I am authenticating my users through an API call - getting back a JWT Token - and using this token for future requests, this way I can use Context.User.Identity.Name in my hub methods: public static async Task<string> GetValidToken(string userName, string password) { using (var client = new HttpClient(

how to pass the result model object out of System.Web.Http.ModelBinding.IModelBinder. BindModel?

你。 提交于 2019-12-11 02:17:42
问题 This is a follow up question to the answer https://stackoverflow.com/a/10099536/3481183 Now that I could successfully extracted the content, apply deserialization and obtain the object that I want. How do I pass it to the action? The provided function BindModel must return a bool value, which is very confusing to me. My code: public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { actionContext.Request.Content.ReadAsStringAsync().ContinueWith(deserialize);

ASP.NET 5: Error with Nuget package in Class library Package

别等时光非礼了梦想. 提交于 2019-12-11 02:05:39
问题 I start playing with VS2015 community version and ASP.NET 5. I have added a new class library (Package) as a new project into my solution but am unable to install a NuGet package in it. After the restoring, I have a "Reference (Errors - see Error List)". If i add a basic Library Class (.dll) as a new project into my solution and try to install the same NuGet package, it works beautifully as it used to. Perhaps, I am misunderstanding how this new class library package works and I am trying to

Can I develop an Asp.net core MVC application using Entity Framework 6 (not Entity Framework core)?

纵然是瞬间 提交于 2019-12-11 01:38:28
问题 I want to use ASP.NET Core with my new project as I heard that it's faster. However, the project will use extensive database accessing feature of which some are not supported by Entity Framework Core . I want to know, is it possible to develop an ASP.NET Core MVC application using Entity Framework 6 (not Entity Framework Core )? 回答1: Based on the documentation of ASP.NET Core, it says: To use Entity Framework 6, your project has to compile against the full .NET Framework, as Entity Framework

Redirect to Action is not working With ASP.NET core

浪子不回头ぞ 提交于 2019-12-11 01:14:46
问题 I have my login view which wants to redirect to Clients page after successful login. To do that I am using , [HttpPost] public async Task<IActionResult> Login(LoginViewModel model) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Username, model.Password, model.Rememberme, false); if (result.Succeeded) { if (Request.Query.Keys.Contains("ReturnUrl")) { Redirect(Request.Query["ReturnUrl"].First()); } RedirectToAction("Index", "Clients"); } else {

Targetting netcoreapp And The Full net461 Using ASP.Net Core

你离开我真会死。 提交于 2019-12-11 01:05:39
问题 In the recent ASP.Net Core RC2 Preview 1 release of the tooling, the project templates were split into full .NET Framework projects targeting net461 and .NET Core projects targeting netcoreapp1.0 . In the previous world, both of these target frameworks were added in a single project. Can this still be done? What was the reason for splitting them up? 回答1: Both in a single project: Yes you can do that. Create one of them, add the other other framework in the project.json like before. Like Tseng

ASPNET Core pre-RC2 dependency ambiguity

别来无恙 提交于 2019-12-11 01:05:19
问题 I am using: .NET Command Line Tools (1.0.0-rc2-002439) Product Information: Version: 1.0.0-rc2-002439 Commit Sha: ef0c3b2cee Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64 and getting: error CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)' and 'Microsoft

Serilog Additional Properties

房东的猫 提交于 2019-12-11 00:58:23
问题 I work working with Serilog and logging events to SQL Server (using the Serilog, Serilog.Framework.Logging and Serilog.Sinks.MSSqlServer libraries). As part of an MVC6 application, when I log events and set the option to include properties, I see some additional properties in the XML column. If I issue something like the following statement: Log.Information("{Property1}", "Value1"); I see something like the following in the Properties column: <properties> <property key="Property1">Value1<

Form model not validating before POST

百般思念 提交于 2019-12-11 00:58:03
问题 I'm trying to make a registration page in my web application. However, the validation on my form is not working. For example I have my password minimum length be 4 charterers but if I enter a blank password it still makes the POST request. How do I tell the form that the model is not valid and that they should change their password,email, etc? AccountController.cs [HttpPost] public ActionResult Register(RegisterModel model){ if (ModelState.IsValid){ // Insert into database } // There was an

Resharper intellisense suggests wrong path in MVC 6

删除回忆录丶 提交于 2019-12-11 00:36:23
问题 Here is my solution: I want to import site.css . I know the correct path is: <link rel="stylesheet" href="~/css/site.css" /> . But as you can see, Resharper is suggesting me a different path. Follow Resharper intellisense, the path would be: <link rel="stylesheet" href="~/wwwroot/css/site.css" /> . This is a wrong path, and the file will not be imported. So, my question is: how can I fix this in Resharper? How to let Reshaper know that it shouldn't include wwwroot in the path? I'm using