asp.net-mvc-5

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

雨燕双飞 提交于 2019-12-18 04:28:07
问题 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 (are you missing a using directive or an assembly reference?) Severity Code Description Project File Line Error CS0518 Predefined type 'System.Object' is not defined or imported Severity Code Description Project File Line Error CS0518 Predefined type 'System.String' is not defined or imported I got

How do i retrieve the email address when using google auth in mvc 5?

蹲街弑〆低调 提交于 2019-12-18 04:24:09
问题 I have enabled Google Auth only within my asp.net mvc 5 app. I see that when I am redirected to googles auth screen I am asking for permission to view the users name and email address. I then return from Google, log in, and name my new user. I have obviously asked for permission to view the email address, but by default this is not stored. How would I store this in the users table? I have tried editing the options in startup.auth, but there aren't any pertaining to the email. When doing this

Refresh Partial View Div in MVC 5

末鹿安然 提交于 2019-12-18 03:45:13
问题 I am trying to refresh a partial view div in MVC 5 so a table will show new SQL data. However, I'm running into a problem. The way it is now, the div is not refreshing to include new data when I add any new data to my SQL table after page-load...just the data that was in the table on page-load. Here is my Controller: public ActionResult Index() { List<List<object>> result = DataAccess.DataAccess.Read(Build.StringArray("Notifications")); Notifications Notify = new Notifications(); Notify

What is the benefit to using await with an async database call

南笙酒味 提交于 2019-12-18 02:40:09
问题 I am just looking at the default MVC5 project and how it uses async in the controllers. I would like to know what benefit async provides here over simply using synchronous calls: [HttpPost] [ValidateAntiForgeryToken] public async Task<ActionResult> Disassociate(string loginProvider, string providerKey) { ManageMessageId? message = null; //why use an async database call here with await instead of just using a synchronous one? IdentityResult result = await UserManager.RemoveLoginAsync(User

How to add MVC 5 authentication to Unity IoC?

╄→гoц情女王★ 提交于 2019-12-17 23:26:55
问题 I'm currently working on implementing the new ASP.NET MVC 5 out-of-the box authentication into my application. However when using Unity as my IoC, I cannot use any portion of the AccountController because I'm given the error: The type IUserStore`1 does not have an accessible constructor. This is my given unity setup which is called in the global.asax public class DependencyConfig { public static void Initialise() { var container = BuildUnityContainer(); DependencyResolver.SetResolver(new

How to create ASP.Net Identity tables inside existing database?

匆匆过客 提交于 2019-12-17 22:47:01
问题 I am building my first MVC 5 / Entity Framework application. I used the database first method to pull in my data from an existing SQL server. The existing SQL database receives it's data from a separate web forms .net application. Moving forward, the new MVC application and the existing web forms application will share the database. I am using Identity to create user accounts within the MVC application. So at this point, I have 2 data connections in my MVC application. One for the user

How do you consume extra parameters in OAuth2 Token request within .net WebApi2 application

坚强是说给别人听的谎言 提交于 2019-12-17 22:35:04
问题 I have an api specific project in a large .net MVC 5 web solution. I am utilizing the WebApi2 templates out of the box to authenticate a user through the api. Using individual accounts to authenticate, the request body required to get an access token is: grant_type=password&username={someuser}&password={somepassword} This works as expected. However, I need to add a 3rd dimension to the scaffolded method "GrantResourceOwnerCredentials". In addition to checking the username/password, i need to

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

依然范特西╮ 提交于 2019-12-17 22:12:31
问题 I've creating an Asp.Net MVC 5 website. I will need to add customized fields in ApplicationUser and associate (add foreign keys) it with other models. I think I should just use one context type. However, the code scaffold already generate the following ApplicationDbContext class. Can I just put all my public DbSet<...> ... { get; set; } in the class? Or is there a better pattern? namespace MyApp.Models { // You can add profile data for the user by adding more properties to your User class,

ASP.NET Identity login

岁酱吖の 提交于 2019-12-17 21:57:13
问题 I have a website in MVC 5 using ASP.NET Identity to login a user. Everything works great. Now my partner needs to login a registered user in his WinForms app. Does anyone know the password hashing algorythm used by Identity or how can I authenticate the user in the WinForms app? Any tips would be apreciated. Best regards. 回答1: If you are using Microsoft.AspNet.Identity.EntityFramework from the MVC app and the WinForm app has access to the same database, then you should configure it to use the

Where to store Bearer Token in MVC from Web API

痴心易碎 提交于 2019-12-17 21:52:32
问题 Scenario I have an ASP.NET Web API that uses the OAuth Password Flow to provide Bearer Tokens to gain access to its resources. I'm now in the process of making an MVC app that will need to use this API. The plan is to have the MVC controllers make calls to the API on behalf of the client browser. The ajax requests from the browser will hit the MVC controllers and then the API calls are made. Results are then fed back to the client as JSON and handles in java-script. The client should never