asp.net-mvc-5

How to authenticate WPF Client request to ASP .NET WebAPI 2

折月煮酒 提交于 2019-12-04 09:30:56
问题 I just created an ASP .NET MVC 5 Web API project and added the Entity Framework model and other things to get it working with ASP. NET Identity. Now I need to create a simple authenticated request to the standard method of that API out there from the WPF Client app. ASP .NET MVC 5 Web API code [Authorize] [RoutePrefix("api/Account")] public class AccountController : ApiController // GET api/Account/UserInfo [HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)] [Route("UserInfo")]

NullReferenceException with Owin

白昼怎懂夜的黑 提交于 2019-12-04 08:58:54
I've just cloned a project to a new machine and I'm getting a hard-to-debug NullReferenceException on a MVC site with OWIN: [NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Owin.Security.Cookies.<AuthenticateCoreAsync>d__0.MoveNext() +664 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 Microsoft.Owin.Security.Infrastructure.<BaseInitializeAsync>d__2.MoveNext() +860

Asp.Net MVC 5 How to send ViewBag to Partial View

强颜欢笑 提交于 2019-12-04 08:54:55
I have a _LoginPartial View and want to send data to it by ViewBag, but the Controller that I'am sending data from, doesn't have a View. public PartialViewResult Index() { ViewBag.sth = // some data return PartialView("~/Views/Shared/_LoginPartial.cshtml"); } This code didn't work for me. It seems you're expecting this Index action to be called when you do: @Html.Partial('_LoginPartial') . That will never happen. Partial just runs the partial view through Razor with the current view's context and spits out the generated HTML. If you need additional information for your partial, you can specify

There was an error running the selected generator . try rebuilding the project

随声附和 提交于 2019-12-04 08:31:42
When I create the Scaffold and add the Model class then I am getting these error "There was an error running the selected generator . try rebuilding the project" I have three Model class : 1.Department.CS 2.Designation.cs 3.CompanyDBContext.cs Database : I have two table in database, 1. Department(deptID,deptName,Description) 2. Designation(desgtID,desgName,description) Objective :- I want to create one view page for these scenario. Like this Insert Name of Form (TextBox) + Department Name (Dropdown list box) + Designation Name (Dropdown list box) 1.Department.CS namespace mvcAppraisalSystem

EF6 + Postgres relation dbo.AspNetUsers does not exist

与世无争的帅哥 提交于 2019-12-04 07:58:46
I have been following this post on using PostgreSQL with EF6 http://www.jasoncavett.com/blog/postgresql-and-entity-framework-6-code-first/ . I have started a brand new MVC5 project hoping to use Postgres in my application for backend. The application starts up fine however when you go to register a user (I selected individual authentication) I get the following error messsage ERROR: 42P01: relation "public.AspNetUsers" does not exist I am unsure as to how to resolve this problem. The error happens on line 155 which can be seen here More information can be provided if needed. I had ran the

How does @Html.BeginForm() work? and search result in Microsoft ASP.Net MVC 5 tutorial?

六月ゝ 毕业季﹏ 提交于 2019-12-04 07:51:49
问题 I am working on MVC 5 Asp.Net and following this tutorial. I am wondering how the heck does this fetch the result when I click the Filter button? There comes a point where this code is added in Movie/view/Index.cshtml @using (Html.BeginForm()) { <p> Title: @Html.TextBox("SearchString") <br /> <input type="submit" value="Filter" /></p> } Now as far as I know, it creates a textbox and a button on screen. But how is this button calling the search(index) function and passing the value of textbox

How do I upload a file to Azure blob storage from a MVC view

醉酒当歌 提交于 2019-12-04 07:46:45
I am coding a MVC5 internet application and would like some help to upload a file from my own filesystem to an Azure Blob. Here is my Azure upload code function: public void UploadFileToBlobStorage(string containerName, string blockBlogName, string fileName) { // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container.

The type RoleStore<IdentityRole> is not assignable to service IRoleStore<IRole>

风流意气都作罢 提交于 2019-12-04 07:33:35
I'm trying to set up dependency injection with Autofac for project using MVC5 and EF6. I'm having a hard time figuring out how to decouple correctly the EntityFramework.RoleStore<EntityFramework.IdentityRole> implementation. I would like have dependency only on Identity.IRoleStore<Identity.IRole> but I'm aware that for generic classes I need to specify the concrete implementation, not the interface. This is what I tried: builder.RegisterType<IdentityRole>().As<IRole>(); builder.RegisterType<RoleManager<IRole>>(); builder.RegisterType<RoleStore<IdentityRole>>().As<IRoleStore<IRole>>(); builder

How do I show Exception message in shared view Error.cshtml?

风格不统一 提交于 2019-12-04 07:25:35
If I start with a new MVC 5 project, in web.config setting customErrors mode="on" allows the shared view 'Error.cshtml' to show when I force (raise) an exception, but it only shows the following text... Error. An error occurred while processing your request. How do I pass information to this view to display more relevant info, such as what error occurred? Can I use this view if I use the Global.asax method... protected void Application_Error() ? Denys Override the filter: // In your App_Start folder public class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection

How to get data to Dropdownlist from database in html view

雨燕双飞 提交于 2019-12-04 07:11:09
问题 I am creating an web page in which have a Dropdownlist . I have to retrieve data for the drop_down_list from the database. Is there any way to get data from the database to the html view my html code: <select name="drop down"><option value="1">@test.list[i]</option></select> I got the database value to the list variable but I don't know how to pass the data to the html view. Please help me in this issue.Thanks 回答1: You need to create Select List of Items : Your Action with List of Items in