tagged [asp.net-mvc-5]

ASP.NET MVC Routing based on domain & hostname

ASP.NET MVC Routing based on domain & hostname I am new to ASP.NET MVC, most of my experience is on ASP.NET Webforms. Is there a way to setup routing based on domain/hostname, i.e. www.domain.com goes...

Set default global json serializer settings

Set default global json serializer settings I'm trying to set the global serializer settings like this in my `global.asax`. ``` var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatt...

Getting controller name from razor

Getting controller name from razor I seem to be having a difficult getting something that should be easy. From within my view, using Razor, I'd like to get the name of the current controller. For exam...

17 Oct at 00:3

How to check if session value is null or session key does not exist in asp.net mvc - 5

How to check if session value is null or session key does not exist in asp.net mvc - 5 I have one ASP.Net MVC - 5 application and I want to check if the session value is null before accessing it. But ...

25 Jan at 15:32

Verify newly entered password of logged in user

Verify newly entered password of logged in user User is logged in and wants to do something major and I want them to re-enter their password so I can make sure that they are the user that is logged in...

When unit testing, how do I mock a return null from async method?

When unit testing, how do I mock a return null from async method? Normally, I mock my repo like so: But, in my code, I check to see if the member is not found, i.e. GetMemberAsync ret

How to bind IAuthenticationManager with Ninject in ASP.NET MVC 5?

How to bind IAuthenticationManager with Ninject in ASP.NET MVC 5? I'm trying to bind `IAuthenticationManager` with Ninject so it can be injected into my `AuthenticationService`. The problem is that I ...

How to add claims during user registration

How to add claims during user registration I'm using ASP.NET MVC 5 project with identity 2.1.0 and VS2013 U4. I want to add claims to user during registration in order to be stored in db. These claims...

There was an error running the selected code generator: 'Object reference not set to an instance of an object.' Error?

There was an error running the selected code generator: 'Object reference not set to an instance of an object.' Error? [](https://i.stack.imgur.com/SNj5M.png) I have tried all the solution like repair...

24 Aug at 16:29

How require authorization within whole ASP .NET MVC application

How require authorization within whole ASP .NET MVC application I create application where every action beside those which enable login should be out of limits for not logged user. Should I add `[Auth...

Downloading of zip file through ASP.NET MVC using DotNetZip

Downloading of zip file through ASP.NET MVC using DotNetZip I have created a text file in a folder and zipped that folder and saved @same location for test purpose. I wanted to download that zip file ...

5 Jan at 23:1

How do I properly register AutoFac in a basic MVC5.1 website?

How do I properly register AutoFac in a basic MVC5.1 website? AutoFac has recently been updated for MVC 5.1 but at the time of writing I find that the documentation is lacking (especially for a simple...

Does autofac supports the new Web Api 2

Does autofac supports the new Web Api 2 I'm developing a web api as part of a MVC/API ASP.NET on VS 2013, MVC 5, API 2, but my `AutofacWebApiDependencyResolver` throws an exception every time I try to...

GenerateEmailConfirmationTokenAsync default expiration timespan

GenerateEmailConfirmationTokenAsync default expiration timespan What is default expiration timespan of GenerateEmailConfirmationTokenAsync? and what kind of errors should I get from ConfirmEmailAsync?...

About Enum and DataAnnotation

About Enum and DataAnnotation I have this Enum (Notebook.cs): Also this property in my class (TIDepartment.cs): It's working perfectly, I just have one "problem": I created an EnumDDLFor and it's show

Models.ApplicationDbContext for all models in an Asp.Net MVC 5 application?

Models.ApplicationDbContext for all models in an Asp.Net MVC 5 application? I've creating an Asp.Net MVC 5 website. I think I should just use one context type. However, the code scaffold already gener...

Asp.Net MVC 5 without Owin?

Asp.Net MVC 5 without Owin? Mvc 5 seems to depend on Owin, which is great if you want to self host or run on a Mac. But lets assume I just want to run under IIS just like the previous versions and I'm...

19 Apr at 21:27

How to create dependency injection for ASP.NET MVC 5?

How to create dependency injection for ASP.NET MVC 5? Creating Dependency Injection with ASP.NET Core is fairly easy. The documentation explains it very well [here](https://learn.microsoft.com/en-us/a...

Can you extend HttpContext.Current.User.Identity properties

Can you extend HttpContext.Current.User.Identity properties Is there a way to override `HttpContext.Current.User.Identity` to add another property (screen name)? My application uses `Identity` and I'v...

12 Aug at 20:19

How to add Web API to an existing ASP.NET MVC (5) Web Application project?

How to add Web API to an existing ASP.NET MVC (5) Web Application project? Assuming you forgot to tick the Web API checkbox (add it to the project) when making a new MVC (5) project, what do you need ...

How to get current user, and how to use User class in MVC5?

How to get current user, and how to use User class in MVC5? - - `User``Items``Id``Item``User``List` I'm using "Individual User Accounts" from the MVC template. Tried these: - [How do I get the current...

How to configure StructureMap for asp.net MVC 5

How to configure StructureMap for asp.net MVC 5 I'm getting below error. I setup it similar to asp.net mvc 4. > No parameterless constructor defined for this object. Description: An unhandled excepti...

Can I run MVC 5 application on .NET Framework 4.0?

Can I run MVC 5 application on .NET Framework 4.0? I have my MVC 5 application that I create in VS 2013. Now I'm trying to deploy this application and I have a question: Can I deploy MVC 5 on the serv...

How can I use Url.Action with list parameters?

How can I use Url.Action with list parameters? Say I have an action method: The way the MVC model binding works, it expects a list of category like this: So my questions are: ### How do I create that ...

14 Feb at 17:10

How to set Swagger as default start page?

How to set Swagger as default start page? How do I set Swagger as the default start page instead of `/Account/Login`? I'm using ASP.NET MVC 5.x + Angular 1.x. # Update Current code: ``` public static ...