asp.net-mvc-5

How to access Model Property added to ApplicationUser in Layout file

人走茶凉 提交于 2019-12-12 04:55:34
问题 I am a beginner in ASP.Net MVC web development. And I want to know how can I access extra property added in my ApplicationUser model in layout file? As of now if I have to access a property in the razor file I add @model myModel at top of Razor file and then I am able to access the property by @Model.MyProperty . Suppose I added FirstName property in my Application User like below: public class ApplicationUser : IdentityUser { public string FirstName { get; set; } } Now in my Login Partial I

An unhandled exception occurred during the execution of the current web request, “Не найден указанный модуль”

亡梦爱人 提交于 2019-12-12 04:41:06
问题 I'm following on the MVC tutorial of Rick Anderson , here , page 4 , after added the Model and Database . However , when I try to go to the URL of : http://localhost:2815/Movies/Index I get this : And this : Server Error in '/' Application. Не найден указанный модуль Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System

Asp.Net Identity - IdentityDbContext<TUser> causing problems for fields added to AspNetRoles table

南楼画角 提交于 2019-12-12 04:41:06
问题 IdentityDbContext causing problems for properties/fields added to AspNetRoles I believe the problem is here with IdentityDbContext taking an IdentityUser type: public class MyIdentityDb : IdentityDbContext<ApplicationUser> { public IdentityDb() : base("IdentityDb") { } } But let me explain… It is wonderful that we can add fields to the AspNetUsers table by adding properties to our ApplicationUser class that inherits from IdentityUser. Example: public class ApplicationUser : IdentityUser {

MVC5 How can I retrieve all users from Azure Active Directory

余生长醉 提交于 2019-12-12 04:35:12
问题 Hi I'm relatively new to Azure. I want to create a dropdownlist that contains all the user's display name from the Azure's Active Directory but I'm not sure how to do it. I briefly looked at the graph API from https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations but I don't know how to call it in MVC nor getting the JSON data that contains the display name. Any help or code example will be appreciated 回答1: You could get started using this Azure AD sample https://github

Unable to cast object of type 'DBContext.Models.Contact' to type 'System.Data.Entity.Infrastructure.IObjectContextAdapter'

独自空忆成欢 提交于 2019-12-12 04:34:53
问题 I am trying to implement "Repository-Pattern" and "Edit" method in Contact-Controller is making use of "Attach Method" in Contact-Repository is throwing Error. Additional information: Unable to cast object of type 'Contacts.Models.Contact' to type 'System.Data.Entity.Infrastructure.IObjectContextAdapter'. Before This issue i faced another issue of ObjectStateManger Extension not found error in the code : entities.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); So i had to

Update mutiple records in database MVC 5 EF

亡梦爱人 提交于 2019-12-12 04:28:10
问题 Good evening, Now I'll describe my situation: Here is my Model: [Table("Items")] public class Item { [Key] public string Id { get; set; } public DateTime Generated { get; set; } public string Content { get; set; } public string UrlSeo { get; set; } public bool IsActive { get; set; } public int Quantity { get; set; } public decimal Price { get; set; } } I;m implementing CRUD operations to DB records, but I need implement one more Action, I need to Update for example UrlSeo property in selected

Google Log in Issue in published website but fine in dev mode

时光毁灭记忆、已成空白 提交于 2019-12-12 04:28:07
问题 I am working on one of the log in form in ASP.Net MVC 5. And the google login is not working properly. When I run the project as localhost I am able to redirect to the google's log in page. But when I publish the website I get error as Error: redirect_uri_mismatch . I am new to all this please guide me. below is code snippet. var ClientID = "*************"; var url = "https://accounts.google.com/o/oauth2/auth?"; var parameters = "response_type=code&client_id=".concat(ClientID).concat("

Rendered partial view does not match model

眉间皱痕 提交于 2019-12-12 04:26:06
问题 So I've written some code to allow adding and removing elements from a collection dynamically in ASP.NET MVC using AJAX. Adding new items to the collection works as expected, but removing does not. The model collection is updated as expected (the appropriate item is removed by index), but the rendered HTML consistently shows that the last item has been removed (rather than the one at the specified index). For example, let's say I have the following items: Foo Bar Baz When I click "remove"

After converting Excel to PDF Unable to open that file

China☆狼群 提交于 2019-12-12 04:18:36
问题 I have tried to convert excel to PDF and I could convert it. but while opening that file I am getting error as following in image. I have refer this link How do I convert Word files to PDF programmatically? from this link I could solve my Word to PDF file conversion issue. where I don't have to install office on server and same thing I want to do for excel and PPT files. My code : // Create a new Microsoft Excel application object Microsoft.Office.Interop.Excel.Application excelApplication =

MVC 5, globalize, validate german date: How to bundle the js-scripts?

女生的网名这么多〃 提交于 2019-12-12 04:14:35
问题 In the answer to this question (MVC 5 - can not get globalisation running) I solve the problem with a bunch of "<sript src="..." declarations and some js. What I not managed: I want to bundle the scripts. If I try it like this (excerpt from bundleConfig.cs): bundles.Add(new ScriptBundle("~/bundles/jqueryvalDe").Include( "~/Scripts/jquery.validate.js", "~/Scripts/jquery.validate.unobtrusive.js", "~/Scripts/cldr.js", "~/Scripts/cldr/event.js", "~/Scripts/cldr/supplemental.js", "~/Scripts/cldr