asp.net-core-mvc

AOP for C# dotnet core 2.0, access method parameter values before method body runs

这一生的挚爱 提交于 2019-12-04 17:06:40
This is my method, I am trying to validate componentToSave (or access method parameter values) and throw an exception before method body even runs. public Component SaveComponent(Component componentToSave) { ... } I tried using PostSharp but it is not free and also there were other libraries that rely on AutoFac as IoC but in my current setup I am using dotnet core's built-in dependency injection. I tried NConcern and it relies on CNeptune and CNeptune itself relies on a .exe file for post-compile binding and I currently use Linux for both development and production so I cannot use it, even I

Change component view location in Asp.Net 5

老子叫甜甜 提交于 2019-12-04 15:41:28
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 possible? That convention is only applied if you create a view component that derives from the base

How to run dynamic SQL query in Entity Framework 7 that auto-maps to Entities (SqlQuery<T>)?

邮差的信 提交于 2019-12-04 15:27:57
I have an existing app that I am trying to upgrade from MVC5/EF6 to MVC6/EF7. We dynamically create some of our SQL tables, and as a result, have made use of the System.Data.Entity.Database.SqlQuery method to automatically map to entities that we use throughout our application. This method seems to have gone away (i.e. not part of Microsoft.Data.Entity.Infrastructure.Database ) in EF7 (or is not yet implemented). Are there plans to re-implement this method in EF7 or is there another way to accomplish this? Our project is kind of dead in the water until we figure this out. Edited on May 20,

Redirect to URL instead of 401 for unauthenticated

删除回忆录丶 提交于 2019-12-04 15:25:23
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 by using the RC-2 nightly build version. Now my problem is that I want to be able to redirect to an

How to register ILogger for injection in ASP.NET MVC 6

倖福魔咒の 提交于 2019-12-04 14:58:43
问题 I have a ASP.NET MVC 6 (beta-4) app. public void ConfigureServices(IServiceCollection services) { // Logging services.AddLogging(); // ... } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) { // Add the console logger. loggerfactory.AddConsole(minLevel: LogLevel.Warning); // ... } And I have a controller... public class HomeController : Controller { ILogger _logger; public HomeController(ILogger logger) { _logger = logger; } // ... } But

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

泪湿孤枕 提交于 2019-12-04 14:57:13
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.Combine(SolutionRoot, "src", "web", "wwwroot")); var app = new WebApplication(project, 8080); server = new

Will there be a SSRS reportviewer in ASP.NET 5 MVC 6?

巧了我就是萌 提交于 2019-12-04 14:16:54
I am working on upgrading an ASP.NET 4.0 WebForms app to MVC6 and cannot find a solution for displaying SSRS reports. With the absents of System.Web the Microsoft ReportViewer control no longer works. What is the best practice for displaying SSRS reports on the web in ASP.NET 5? @Brian - ASP.NET MVC 6 is still in beta stage, its very early to plan for upgrading ASP.NET 4 web forms to MVC 6. Please try using ASP.NET MVC 5 for upgrading web forms, it (MVC5) will be there for many years to come. ASP.NET 5 will take good amount of time to mature, so don't hurry. There's no direct support for the

Required dependencies for Resolver or ServiceProvider for using ICompositeViewEngine

谁说胖子不能爱 提交于 2019-12-04 14:08:58
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: https://github.com/aspnet/Mvc/issues/3091 However, I am not sure about what dependencies or frameworks I

AspNet Core Generate and Change Email Address

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 14:07:30
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 not want to send over the new email address in the email link but also do not want to make them type

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

一曲冷凌霜 提交于 2019-12-04 13:40:55
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 : IdentityDbContext<AppUser> { public AppIdentityDbContext(DbContextOptions<AppIdentityDbContext> options) : base