Questions tagged [asp.net-mvc-5]

ASP.NET MVC 5 is the fifth major version of the ASP.NET Model-View-Controller platform for web applications.

asp.net-mvc-5
Filter by
Sorted by
Tagged with
402 votes
22 answers
127k views

OwinStartup not firing

I had the OwinStartup configuration code working perfectly and then it stopped working. Unfortunately I'm not sure exactly what I did to get it to stop working and am having a really hard time ...
Jeff Treuting's user avatar
273 votes
20 answers
453k views

HTTP Error 500.19 and error code : 0x80070021

I have a simple webAPI build by Visual Studio 2013. It works well when I run it from VS13 but when I copy the project in local IIS it gives me the following error. HTTP Error 500.19 - Internal Server ...
Umar Abbas's user avatar
  • 4,111
258 votes
11 answers
361k views

ASP.NET MVC 5 - Identity. How to get current ApplicationUser

I have an Article entity in my project which has the ApplicationUser property named Author. How can I get the full object of currently logged ApplicationUser? While creating a new article, I have to ...
Ellbar's user avatar
  • 4,024
221 votes
26 answers
490k views

'router-outlet' is not a known element

I have a mvc 5 project with a angular frontend . I wanted to add routing as described in this tutorial https://angular.io/guide/router. So in my _Layout.cshtml I added a <base href="/"> and ...
Molo's user avatar
  • 2,233
218 votes
8 answers
187k views

How to add MVC5 to Visual Studio 2013?

I'm starting a new project, and would like to give a try to MVC 5 (I have built a web app using MVC 4 before). In Visual Studio 2013, I click the New Project and navigate to Visual C# > Web > Visual ...
developer82's user avatar
  • 13.5k
218 votes
3 answers
79k views

What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface?

Looking at ASP.NET Identity (new membership implementation in ASP.NET), I came across this interface when implementing my own UserStore: //Microsoft.AspNet.Identity.Core.dll namespace Microsoft....
Brian Chavez's user avatar
  • 8,303
218 votes
4 answers
160k views

ASP.NET Identity DbContext confusion

A default MVC 5 App comes with this piece of code in IdentityModels.cs - this piece of code is for all the ASP.NET Identity operations for the default templates: public class ApplicationDbContext : ...
PussInBoots's user avatar
  • 11.5k
218 votes
3 answers
81k views

Do I need a Global.asax.cs file at all if I'm using an OWIN Startup.cs class and move all configuration there?

Let's say for example in a brand new ASP.NET MVC 5 application made from the MVC with Individual Accounts template, if I delete the Global.asax.cs class and move it's configuration code to Startup.cs ...
user avatar
189 votes
15 answers
106k views

Unauthorised webapi call returning login page rather than 401

How do I configure my mvc/webapi project so that a webapi method called from a razor view doesn't return the loginpage when its unauthorised? Its a MVC5 application which also has WebApi controllers ...
Tim's user avatar
  • 7,381
162 votes
9 answers
226k views

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

How can I get the id of the currently logged in user in MVC 5? I tried the StackOverflow suggestions, but they seem to be not for MVC 5. Also, what is the MVC 5 best practice of assigning stuff to ...
Adam Szabo's user avatar
  • 11.4k
160 votes
12 answers
177k views

GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration

I recently started following this guide to migrate my project to .NET 4.5.1 and Web Api 2. The very first thing MS developer Rick Anderson asks you to do is change: WebApiConfig.Register(...
nzondlo's user avatar
  • 4,176
158 votes
1 answer
109k views

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 to do add Web API and get it working? There are a bunch of migration ...
lko's user avatar
  • 8,281
139 votes
6 answers
125k views

How to extend available properties of User.Identity

I'm using MVC5 Identity 2.0 for users to log into my website, where the authentication details are stored in an SQL database. Asp.net Identity has been implemented in a standard way as can be found in ...
RobHurd's user avatar
  • 2,041
137 votes
4 answers
172k views

How to implement oauth2 server in ASP.NET MVC 5 and WEB API 2 [closed]

First I'll sketch my project: For my internship I need to add functionality to an existing system. A 3rd party client must be able to access data from AX Webservices once he is authorised by the user ...
Robin's user avatar
  • 2,713
134 votes
12 answers
237k views

MVC 5 Access Claims Identity User Data

I am developing an MVC 5 web application using Entity Framework 5 Database First approach. I am using OWIN for the authentication of Users. Below shows my Login method within my Account Controller. ...
tcode's user avatar
  • 5,085
132 votes
26 answers
100k views

Visual Studio 2013 IntelliSense stops working for ASP.NET MVC5 Controllers

I am facing a weird problem in my Visual Studio 2013 ASP.NET MVC 5 project. All of a sudden, the IntelliSense in the Controller classes of the MVC 5 project are not working at all. I have other class ...
Emran Hussain's user avatar
120 votes
3 answers
51k views

What is the advantage of using async with MVC5?

What is the difference between: public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { IdentityResult result = IdentityManager.Authentication....
user avatar
116 votes
6 answers
126k views

EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType

I am working with Entity Framework Code First and MVC 5. When I created my application with Individual User Accounts Authentication I was given an Account controller and along with it all the required ...
J86's user avatar
  • 14.8k
115 votes
29 answers
263k views

The type or namespace name 'System' could not be found

I have the following errors (and more) in all my views (*.cshtml) when opening my project in Visual Studio 2015 Professional. Error CS0246 The type or namespace name 'System' could not be found (...
Hélder Gonçalves's user avatar
114 votes
11 answers
162k views

How do I install ASP.NET MVC 5 in Visual Studio 2012?

Is there a way to install ASP.NET MVC 5 in Visual Studio 2012? I've tried using NuGet (http://www.nuget.org/packages/Microsoft.AspNet.Mvc). But I think that it should come as a Visual Studio ...
Sreginogemoh's user avatar
  • 1,309
109 votes
6 answers
143k views

How to get JSON object from Razor Model object in javascript

In viewmodel object, below is the property: public IList<CollegeInformationDTO> CollegeInformationlist { get; set; } In VIEW, javascript is as follow: var obj = JSON.stringify('@Model....
dsi's user avatar
  • 3,319
109 votes
4 answers
176k views

How to set Default Controller in asp.net MVC 4 & MVC 5

How do I set Default Controller for my ASP.NET MVC 4 project without making it HomeController? How should I setup a default Area when the application starts?
Adrian10 BEN's user avatar
  • 1,283
105 votes
11 answers
141k views

ASP.NET Identity change password

I need ability to change password for user by admin. So, admin should not enter a current password of user, he should have ability to set a new password. I look at ChangePasswordAsync method, but this ...
Oleg Sh's user avatar
  • 8,803
98 votes
7 answers
68k views

MVC 5 Seed Users and Roles

I have been playing about with the new MVC 5, I have a few models, controller and views setup using code first migrations. My question is how do I seed users and roles? I currently seed some ...
MrBeanzy's user avatar
  • 2,286
94 votes
7 answers
137k views

How to get 'System.Web.Http, Version=5.2.3.0?

I just created an MVC5 project and added several packages from nuget, but then when I compiled the project, i got this error. It seems one of the packages really depends on system.web.http version 5....
John Hadikusumo's user avatar
93 votes
3 answers
60k views

Async PartialView causes "HttpServerUtility.Execute blocked..." exception

I have a partial view that tries to retrieve a IEnumerable<Post> from the database using async... Method public static class PostService { public static int PostsPerPage = 50; public ...
BrunoLM's user avatar
  • 99k
91 votes
11 answers
152k views

Creating Roles in Asp.net Identity MVC 5

There is very little documentation about using the new Asp.net Identity Security Framework. I have pieced together what I could to try and create a new Role and add a User to it. I tried the ...
colbyJax's user avatar
  • 1,053
90 votes
22 answers
138k views

The model backing the 'ApplicationDbContext' context has changed since the database was created

First of all, I have not seen this error anywhere else and I guess it's not a replicate so please read the whole situation first. Everything was working just fine then I tried to update one of my ...
Ahmad Hamdi's user avatar
  • 1,260
89 votes
21 answers
89k views

IntelliSense in Razor files (.cshtml) stopped working

Intellisense does not work in razor files: In my web.conifg file (in the Views folder) is apparently correct: <?xml version="1.0" encoding="utf-8"?> <configuration> <...
ridermansb's user avatar
  • 10.9k
89 votes
5 answers
68k views

What / why is Roslyn "needed" in /bin folder of Asp.Net

There are a bunch of related questions on this, though most of the answers define Roslyn and/or provide a "fix" to some issue (exe, with hosting providers, etc.) What I can't seem to track down is ...
EdSF's user avatar
  • 11.9k
88 votes
9 answers
60k views

ASP.NET Identity with EF Database First MVC5

Is it possible to use the new Asp.net Identity with Database First and EDMX? Or only with code first? Here's what I did: 1) I made a new MVC5 Project and had the new Identity create the new User and ...
Patrick T's user avatar
  • 901
85 votes
24 answers
91k views

Asp.NET Identity 2 giving "Invalid Token" error

I'm using Asp.Net-Identity-2 and I'm trying to verify email verification code using the below method. But I am getting an "Invalid Token" error message. My Application's User Manager is like this: ...
Julio Schurt's user avatar
  • 2,054
83 votes
2 answers
14k views

Post an HTML Table to ADO.NET DataTable

I have a HTML table as below in my View: <table id="tblCurrentYear"> <tr> <td>Leave Type</td> <td>Leave Taken</td> <td>Leave ...
RKh's user avatar
  • 14k
82 votes
6 answers
113k views

How can I implement a theme from bootswatch or wrapbootstrap in an MVC 5 project?

I am about to create a new ASP.Net MVC5 web application. I would like to use a theme from bootswatch or wrapbootstrap in the application, but cannot find a set of instructions on how to do this.
Peter Loudon's user avatar
80 votes
5 answers
55k views

MVC5 Claims version of the Authorize attribute

I'm trying out some of the new stuff in VS2013 RC with MVC5 and the new OWIN authentication middleware. So, I'm used to using the [Authorize] attribute to limit actions by role but I'm trying to use ...
EightyOne Unite's user avatar
79 votes
7 answers
40k views

Error renaming ASP.NET MVC project

I have copied a previous project and renamed it. Once I had successfully renamed all the name spaces and it build correctly. I got the following error when I ran the application: The following errors ...
Zapnologica's user avatar
  • 22.4k
78 votes
12 answers
115k views

Updating user data - ASP.NET Identity

I've added custom fields to the ApplicationUser class I've also created a form through which the user can enter/edit the fields. However for some reason I'm not able to update the fields in the ...
galdin's user avatar
  • 12.9k
78 votes
21 answers
50k views

New Asp.Net MVC5 project produces an infinite loop to login page

I am creating a brand new projet with Visual Studio 2013, I choose Asp.Net MVC and the framework 4.5.1 The project is created, then, I do nothing else than F5 to start the default web page. ...
Patrick Desjardins's user avatar
76 votes
11 answers
66k views

Object reference not set to an instance of an object in _Layout.cshtml after updated packages

The project was running fine until I updated all NuGet packages via NuGet Manager (I was trying to get the latest OWIN packages). This error is in the _Layout.cshtml and I have not touched it at all. ...
Franva's user avatar
  • 6,819
74 votes
9 answers
49k views

No OWIN authentication manager is associated with the request

After trying to enable owin & AspNet Identity to my Web Api project (in VS 2013 + .Net 4.5.1) I get the following error in each valid or unvalid(request to none exist controller) requests : <...
Mahmoud Moravej's user avatar
74 votes
1 answer
51k views

SignInManager,what it is and how,when to use?

I am exploring SignInManager class. But the information given on MSDN is very useless. It only tells what are the methods and properties provided. What I am looking for is, What is SignInManager? How ...
user786's user avatar
  • 4,124
74 votes
1 answer
2k views

ASP.NET MVC OutputCacheAttribute with external cache providers

After switching an ASP.NET MVC 5 application to Azure Redis (Microsoft.Web.RedisOutputCacheProvider Nuget package) I was surprised to see that OutputCacheAttribute when set to use either ...
UserControl's user avatar
  • 14.9k
72 votes
8 answers
53k views

MVC5, Web API 2 and Ninject

I have created a new MVC5 project with Web API 2, I then added the Ninject.MVC3 package from NuGet. Constructor injection is working fine for the MVC5 controllers, but i am getting an error when ...
Declan's user avatar
  • 1,850
69 votes
9 answers
63k views

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 and this guy has a killer video to explain it. However, I want to do the same thing with ...
Jaylen's user avatar
  • 39.7k
69 votes
5 answers
50k views

How to change type of id in Microsoft.AspNet.Identity.EntityFramework.IdentityUser

(ASP.NET MVC 5, EF6, VS2013) I'm trying to figure out how to change the type of the "Id" field from string to int in the type: Microsoft.AspNet.Identity.EntityFramework.IdentityUser in order to ...
BenjiFB's user avatar
  • 4,591
68 votes
5 answers
37k views

Is ASP.NET MVC 5 incompatible with the WebMatrix SimpleMembershipProvider?

We have an existing application that was build on ASP.NET MVC 4 & Web API. The admin parts of the site use Simple Membership. I'm interested in upgrading the application to MVC 5 / Web API 2, to ...
Sixten Otto's user avatar
  • 14.9k
67 votes
7 answers
63k views

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 example, if I'm here: http://www....
Icemanind's user avatar
  • 48.1k
67 votes
11 answers
25k views

ASP.NET MVC5 OWIN Facebook authentication suddenly not working

Update 2017! The issue I had when I posted the original question has got nothing to do with the recent changes Facebook made when they forced everyone to version 2.3 of their API. For a solution to ...
HaukurHaf's user avatar
  • 13.7k
67 votes
4 answers
109k views

How to add claims in ASP.NET Identity

I am trying to find a document or example of how you would add custom claims to the user identity in MVC 5 using ASP.NET Identity. The example should show where to insert the claims in the OWIN ...
Kevin Junghans's user avatar
65 votes
2 answers
50k views

How to add claims in a mock ClaimsPrincipal

I am trying to unit test my controller code which gets the information from the ClaimsPrincipal.Current. In the controller code I public class HomeController { public ActionResult GetName() { ...
Henry's user avatar
  • 665

1
2 3 4 5
314