tagged [asp.net-core-mvc]

Can I execute npm commands directly from the visual studio

Can I execute npm commands directly from the visual studio Can I execute npm commands (e.g. npm init, npm install) directly from Visual Studio 2017 on Asp.Net Core 2.0 project? May be from command lin...

Resolving instances with ASP.NET Core DI from within ConfigureServices

Resolving instances with ASP.NET Core DI from within ConfigureServices How do I manually resolve a type using the ASP.NET Core MVC built-in dependency injection framework? Setting up the container is ...

How to sign out other user in ASP.NET Core Identity

How to sign out other user in ASP.NET Core Identity How can i sign out another user (not the currently logged one) in ASP.NET Core Identity. I know there is a [SignOutAsync()](https://github.com/aspne...

How to add link parameter to asp tag helpers in ASP.NET Core MVC

How to add link parameter to asp tag helpers in ASP.NET Core MVC I have a lot of experience with . Now I learn and have to pass a parameter to link in page. For example I have the following How can I ...

The AuthorizationPolicy named: 'Admin' was not found

The AuthorizationPolicy named: 'Admin' was not found I am learning Authentication/Authorization in .NET Core MVC. I am trying to create a controller that can only be accessed by 'Admin', but get the f...

ASP.NET Core - Custom model validation

ASP.NET Core - Custom model validation In MVC when we post a model to an action we do the following in order to validate the model against the data annotation of that model: If we mark a property as [...

11 Oct at 18:1

Net Core: Convert String to TagBuilder

Net Core: Convert String to TagBuilder The following code converts a `TagBuilder` to a `String`. What is the opposite? How do I convert reverse, a `String` to a `TagBuilder`? Looking for a solution. [...

How to Per-Request caching in ASP.net core

How to Per-Request caching in ASP.net core My old code looks like this: ``` public static class DbHelper { // One conection per request public static Database CurrentDb() { if (HttpContext.Cur...

Produces Data Annotation

Produces Data Annotation I've been learning about Web API recently, and making plans to increase the scalability of my MVC apps, using it. When I finally got into creating a Web API controller, though...

ASP NET Core 2 with Full Framework

ASP NET Core 2 with Full Framework I am unable to find any documentation, or examples, of an ASP.NET MVC Core app running under the full framework. It is supposed to be supported, but as I said I cann...

'DbContextOptionsBuilder' does not contain a definition for UseNpgsql()

'DbContextOptionsBuilder' does not contain a definition for UseNpgsql() I am facing an issue while giving the connectionstring to get it connect to PostgreSQL through the `AddDbContext()` method in Co...

asp.net core 1.0 web api use camelcase

asp.net core 1.0 web api use camelcase On `RC2` the same code returns json format with camel case. After netcore 1.0 release i started new project and the same code is returning json in lowercase. [](...

How to get absolute path in ASP.Net Core alternative way for Server.MapPath

How to get absolute path in ASP.Net Core alternative way for Server.MapPath How to get absolute path in ASP net core alternative way for `Server.MapPath` I have tried to use `IHostingEnvironment` but ...

OverrideAuthorization attribute in .NETCore

OverrideAuthorization attribute in .NETCore In the controller code below, only users who are in the "Administrator" role can access the `GetData()` action method, because of the controller-level `Auth...

Migrate html helpers to ASP.NET Core

Migrate html helpers to ASP.NET Core I'm converting a project to ASP.NET Core. I need to migrate lots of reusable html helpers, but html helpers do not exist in Core. Some are complex, some simple. He...

Unit testing routing in ASP.NET Core 1.0 (ex MVC 6)

Unit testing routing in ASP.NET Core 1.0 (ex MVC 6) As the architecture of ASP.NET Core 1.0 (ex MVC 6 / ASP.NET 5.0) changed significantly, how would one go about unit testing the routing? As an examp...

services.AddControllersWithViews() vs services.AddMvc()

services.AddControllersWithViews() vs services.AddMvc() In order to be able to add controllers in my ASP.NET Core app, I can add either or in `ConfigureServices` method at `Startup` class. It looks li...

7 Jun at 21:8

How to get the database context in a controller

How to get the database context in a controller I am trying all day to figure out to get the `ApplicationDbContext` in the `ManageController.cs` of a default MVC 6 project. I went online and Googled a...

Get the full route to current action

Get the full route to current action I have a simple API with basic routing. It was setup using the default Visual Studio 2015 ASP.NET Core API template. I have this controller and action: So to reach...

How do you enforce lowercase routing in ASP.NET Core?

How do you enforce lowercase routing in ASP.NET Core? In ASP.NET 4 this was as easy as `routes.LowercaseUrls = true;` in the `RegisterRoutes` handler for the app. I cannot find an equivalent in ASP.NE...

Can I generate script of a migration with EF code first and .net core

Can I generate script of a migration with EF code first and .net core I'm building a MVC application with .Net Core and I need to generate the script of a migration. With EF6 I did run the command but...

ASP.NET Core Application Lifecycle

ASP.NET Core Application Lifecycle Is there any current "ASP.NET Core" document(s) about the life cycle? I would like to be able to tie into the life cycle at the right points. Is it similar to the ex...

HttpContextBase namespace could not be found

HttpContextBase namespace could not be found ``` public string GetCartId(HttpContextBase context) { if (context.Session[CartSessionKey] == null) { if (!string.IsNullOrWhiteSpace(context.User.I...

2 Aug at 05:4

Asp.Net MVC Core enabling double escape

Asp.Net MVC Core enabling double escape I am working on a asp.net mvc core application and trying to allow double escaping. My Edit url has a phone number as hyperlink (Ex: +123). I know how to do wit...

Should I use AddMvc or AddMvcCore for ASP.NET Core MVC development?

Should I use AddMvc or AddMvcCore for ASP.NET Core MVC development? I am learning ASP.NET Core MVC from a book, the code snippet in question is as follows: Because t

2 Apr at 16:23