asp.net-core-mvc

@addTagHelper could not load file or assembly

走远了吗. 提交于 2019-12-06 09:23:39
I have an ASP.NET core project generated with Yeoman generator-aspnet. My problem is that I can't use the generator provided tag helper (and my test tag help doesn't work either). The project name is react_tests , and this is the _ViewImports.cshtml file @using react_tests @using react_tests.Models @using react_tests.Models.AccountViewModels @using react_tests.Models.ManageViewModels @using Microsoft.AspNetCore.Identity @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, react_tests I tried replacing the last line with: @addTagHelper "*, react_tests" and @addTagHelper "*,

Redirect to URL instead of 401 for unauthenticated

僤鯓⒐⒋嵵緔 提交于 2019-12-06 09:13:30
问题 I am using ASP.Net 5 MVC 6 with JWT tokens that are created while the user is on another site which this site is a subdomain of. My goal is to pass the token along with the request to this subdomain. If a user happens to try to come to this subdomain url without the proper token in the header then I want to redirect them to the main site login page. After much frustration with the newest RC-1 release and using JWT tokens with a SecureKey instead of certificates. I finally got my code working

Required dependencies for Resolver or ServiceProvider for using ICompositeViewEngine

你。 提交于 2019-12-06 08:42:56
问题 I am trying to use ICompositeViewEngine in ASP.NET Core MVC for substituting ViewEngine from System.Web.Mvc since it is no longer available in .NET Core. I am generally trying to migrate a webform from ASP.NET to ASP.NET Core in this project. I have found the following solution: Where are the ControllerContext and ViewEngines properties in MVC 6 Controller? and I believe that this may resolve my issue. I have also found a similar engine creation with ServiceProvider in a github question:

Starting IIS Express before running Selenium tests on ASP.NET 5 / MVC 6

北城以北 提交于 2019-12-06 07:43:39
问题 I have a VS solution with a "web" project (ASP.NET v5) and a "web.Tests" project (xunit.net 2.1beta) -- one of the tests is checking the rendered pages, and I'm trying to have the test bring up the site automatically, so I don't need to have it running separately/manually. namespace web.Tests { public abstract class BrowserTest : IDisposable { protected readonly IisExpress server; protected readonly IWebDriver driver; protected BrowserTest() { var project = ProjectLocation.FromPath(Path

ASP NET Core MVC - How to configure Out of Process Session State?

雨燕双飞 提交于 2019-12-06 07:27:49
Is there a way to configure out of process session state (using the the Windows State server or SQL Server) with ASP.NET Core MVC? What is important is that session data is backed by a cache. You need to add IDistributedCache implementation to your application services, instead of the in-memory cache, i.e: for SQL Server: services.AddDistributedSqlServerCache(options => { options.ConnectionString = @"your_connection_string"; options.SchemaName = "dbo"; options.TableName = "TestCache"; }); (make sure that you have Microsoft.Extensions.Caching.SqlServer package added in your project) for Redis:

Change the connection string dynamically (per request) on Entity Framework 7 / MVC 6

一笑奈何 提交于 2019-12-06 07:09:54
I have a MVC 6 application on which I need to connect to a different database (i.e. physical file but same schema) depending on who is accessing to it. That is: each customer of the web application will have it's data isolated in an SQL database (on Azure, with different performances, price levels, etc.) but all those databases will share the same relational schema and of course, the Entity Framework context class. var cadConexion = @"Server=(localdb)\mssqllocaldb;Database=DBforCustomer1;Trusted_Connection=True;"; services.AddEntityFramework().AddSqlServer().AddDbContext<DAL.ContextoBD>

Change component view location in Asp.Net 5

余生颓废 提交于 2019-12-06 07:08:02
问题 On ASP.NET 5 a Component view must be in one of two places: Views/NameOfControllerUsingComponent/Components/ComponentName/Default.cshtml Views/Shared/Components/ComponentName/Default.cshtml Is there a way to change this to: Views/NameOfControllerUsingComponent/Components/ComponentName.cshtml Views/Shared/Components/ComponentName.cshtml So basically, remove the folder ComponentName and change the view name from Default.cshtml to ComponentName.cshtml. For me it makes more sense ... Is it

disable the dependency injection scope validation feature in the Program class?

守給你的承諾、 提交于 2019-12-06 06:48:36
问题 My textbook shows an example to build identity services, below is the code: //startup.cs public void Configure(IApplicationBuilder app) { app.UseStatusCodePages(); app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvcWithDefaultRoute(); //try to seed an admin account for the first time the app runs AppIdentityDbContext.CreateAdminAccount(app.ApplicationServices, Configuration).Wait(); } //AppIdentityDbContext.cs public class AppIdentityDbContext :

AspNet Core Generate and Change Email Address

Deadly 提交于 2019-12-06 06:31:39
问题 I am trying to implement a way for users to change their email in AspNetCore so on the Account Management screen I have the change function that will call GenerateChangeEmailTokenAsync on the user manager, then sends the email with the link containing the Token and UserId. My problem is how do I allow the link the change the email address to the new address since ChangeEmailAsync requires the new email address be entered. What is the best practice way of implementing this functionality? I do

Getting 401 accessing secured page with JwtToken under IDS4 and ASP.NET Core 2.2

柔情痞子 提交于 2019-12-06 06:10:52
I have configured the MVC client by adding the following lines. services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(); The error message was, as (kind of) expected, 401 Unauthorized. So I added config for the bearer as suggested by Microsoft . services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(_ => { _.Authority = "http://localhost:5000"; _.Audience = "http://localhost:5002"; }); In my solution, port 5000 hosts the IDS4 provider and port 5002 hosts the MVC application. At that point I got an error because I'm running strictly HTTP for