asp.net-core-mvc

File Not Found Exception Visual Studio 2015

橙三吉。 提交于 2019-12-25 09:08:35
问题 I am getting file not found error though I have the needed file inside the project directory.There are no compilation errors. Here is my startup.cs class: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration; namespace

Unable to load DLL 'sni.dll' - Entity Framework Core

Deadly 提交于 2019-12-25 08:53:39
问题 When using Entity Framework Core in an ASP.Net Core application on Visual Studio 2017 I intermittently get the error "Unable to load 'sni.dll'. Strangely though I have found a temporary fix: restarting my PC. I don't know why the error keeps happening, I don't know what the variable could be. Could anyone shed light on the possible cause? I would offer a full stack trace but it hasn't happened since deciding to post on here, when it next happens I'll be sure to update this. I know for certain

Prerendering failed because of error: ReferenceError: window is not defined

喜欢而已 提交于 2019-12-25 08:32:13
问题 I am new in Angular2, I am trying to go through functionalities with a demo project and used prerendering with Webpack in the code. My code is here- https://github.com/abrarjahin/Dot.NetCore_Angular2_App I am getting this error- An unhandled exception occurred while processing the request. Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: window is not defined at D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1

Delete route not being hit

安稳与你 提交于 2019-12-25 08:29:16
问题 Being battling this issue for too long now it's time to ask for help. The delete route of my .net core mvc app is not being hit. All other routes (Get, Post) are hit just fine. The route config at startup looks like this: app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}/{id?}"); }); The form submit looks something like this: <a class="btn btn-primary" href="~/DisabledRegistrations/Delete/@(Model.Id)">Confirm</a> The controller method looks like this:

How to have a shared environment variable for Angular 2 and ASP.NET Core MVC

我怕爱的太早我们不能终老 提交于 2019-12-25 06:52:27
问题 I have an Angular 2 application in an ASP.NET Core MVC project. Both Angular 2 application and Startup.cs will have code for specific environments, ie. use http://localhost as web service url instead of http://devserver (should be used when published). I need to do this programmatically so I rather do not do this without setting ASPNETCORE_ENVIRONMENT in the OS. Is there a way to accomplish this? 回答1: I've managed to do this. Not sure if it's an optimal solution but it works for me. Please do

Localizaion using Resource file in .Net Core for different Culture

拟墨画扇 提交于 2019-12-25 06:33:11
问题 I am working on .Net Core application and I wanted to implement Localization based on Culture info using Resource files for different culture. I have created Resource files for English and German culture as below: And also I have setup few things and set Default culture and German (de-DE) in Startup.cs as below : public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration

Get current user name in IdentityServer4 & ASP.net Core

房东的猫 提交于 2019-12-25 05:51:13
问题 I followed the example on the website and I am able to get my bearer token. However, how do I get the current user name in my api controller? I used System.Security.Claims.ClaimsPrincipal but name is null. Thanks. 回答1: HttpContext.User.FindFirst("email")?.Value And replace the "email" with name. If the Name claim is not set in the token, the Name claim will also be null. You could also add this to the token in the implementation of the IProfileService. claims.Add(new Claim(JwtClaimTypes.Name,

Can't get .net core MVC to redirect 401 to /Account/Login

╄→гoц情女王★ 提交于 2019-12-25 04:12:31
问题 When I request a controller action that is [Authorize] decorated instead of being redirected to the login page I receive a 401 error. This is a .net core mvc app using the identity template running on IIS express. When i run the app from program.cs the redirect to login works fine. I've added explicit directions to for the cookie authentication to use the /Account/Login redirect both for configuration and services section, as well as configuring Identity to perform this redirect. I can't get

Disable default trace log messages from Web App in Application insights

家住魔仙堡 提交于 2019-12-25 03:36:28
问题 I have created a Web App in Azure and a Web API in .Net core framework following the instructions in this link. Now in my Web App , Application Insights is enabled. In WebAPI has some similar code for logging. public class Startup { public Startup() { } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); var logger = loggerFactory.CreateLogger<ConsoleLogger>(); logger.LogInformation("Executing Configure()"); } }

Can't resolve referenced projects

喜你入骨 提交于 2019-12-25 03:34:59
问题 I created a new ASP.NET 5 MVC project named "TestIt". I then added a new ASP.NET 5 Class Library project named "TestIt.ClassLibrary" to my solution and referenced "TestIt.ClassLibrary" to the MVC project i.e. "TestIt". The problem I'm having is that I can't seem to access any of the methods in the class library project -- at least I can say that IntelliSense is not helping me -- see below: Any idea why I'm having this problem? I want to point out that I updated the projects to use DNX46 (both