asp.net-web-api

UserStore with my own database

坚强是说给别人听的谎言 提交于 2020-01-25 11:31:59
问题 I'm trying to use my own SQL Server database to store the user permissions. I initialize the UserStore with my context like this (I tried with the default constructor also) UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>(new DbEpicerieEntities())); Then I created an empty database and generated the data model for entity. Then I changed the web config for my connection <connectionStrings> <add name="DefaultConnection" connectionString="metadata=res://*

UserStore with my own database

走远了吗. 提交于 2020-01-25 11:31:06
问题 I'm trying to use my own SQL Server database to store the user permissions. I initialize the UserStore with my context like this (I tried with the default constructor also) UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>(new DbEpicerieEntities())); Then I created an empty database and generated the data model for entity. Then I changed the web config for my connection <connectionStrings> <add name="DefaultConnection" connectionString="metadata=res://*

ASP.NET Web Api client to upload file. Pass object to post method

半城伤御伤魂 提交于 2020-01-25 10:38:28
问题 I am trying to upload file to DB server through Web API client VB class as below Public Class Uploads Public Property FileName As String Public Property uploadDateTime As DateTime Public Property File As Byte() End Class Then ASP.NET user upload the file using ASP.NET web form. After receieving this file we need to upload it to server through httpClient If FileUpload1.HasFile Then Dim newFile As New Uploads() newFile.FileName=FileUpload1.FileName newFile.uploadDateTime=DateTime.Now newFile

Angular POST Request “stalled” by Chrome

谁说胖子不能爱 提交于 2020-01-25 09:20:08
问题 One of the post request in our angular application is stalled for more than 2 mins in Chrome . The same Content when re-posted it's posted quickly (less than 6 seconds). The above happens when some ajax request was made earlier on the page followed by the ajax post request. if the same post request was made separately then it works fine. This doesn't happen when the content size is less . Can someone help to resolve the issue? I see error(look at attached screenshot) while transferring the

Programmatically add [AllowAnonymous] attribute to all my controller methods

删除回忆录丶 提交于 2020-01-25 08:47:06
问题 I have a WebAPI2 REST api with several controllers. I use role based authentication. I put [Authorize] attributes on all my controllers and some methods. However, in the DEV environment I want to disable authentication. I was hoping that I can put some code into the WebApiConfig such as: public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); config.EnableCors(new EnableCorsAttribute("*", "*", "*")); //=======================

Basic auth in DNN Web API service

拥有回忆 提交于 2020-01-25 08:25:06
问题 I'm building a library type module for DNN that will house a Web API service that is meant to be called by a separate application. It has one controller that inherits from DnnApiController. I'd like the requests in this service to use basic auth, since the other app has no association with DNN and its users won't be interacting with the portal. All it can do is pass in a username and password (this will happen over SSL). We are running DNN 7.3 which is configured to use standard Forms

Asp.Net MVC4 stopping people requesting or posting data to my API

丶灬走出姿态 提交于 2020-01-25 07:36:06
问题 I want to be able to use AJAX to Get/Post to an API controller in my MVC4 application. However, I don't want anyone to be able to setup a web page and get/post to the controller - only from web pages delivered from my server. So, should I just use a normal controller and return data, rather than an API controller? (or have I misunderstood that using the API controller opens up the web application to any Get/Post?) Thanks, Mark 回答1: This is a possible duplicate of my question here. In a

Get the stream data from WEB API response in windows/ console application

旧城冷巷雨未停 提交于 2020-01-25 06:52:12
问题 I need to download the file from WEB API to windows application via stream data. WEB API : public HttpResponseMessage download(string fileid){ var response = new HttpResponseMessage (); response.statuscode= HttpStatusCode.Ok; response.Content =new StreamContent(filestream);// I have a filestream here . return response; Here content disposition and content type as added after adding the content . In client side I have try the following. HttpResponseMessage file = httpclinet.GetAsync("url")

How to apply paging specifically to a list which is part of a JSON using asp.net OData protocol

风格不统一 提交于 2020-01-25 01:21:09
问题 Below is a get method in my controller. It returns a JSON containing boolean "success', string "message" and a list. How can i query the list using OData? Generally if the return type was IQueryable then the following would work api/Category/all?$top=5 to get the top 5....But what should i do in my case? // Get all Categories [HttpGet] [ActionName("all")] [Queryable] public HttpResponseMessage GetCategoryList() { var categoryList = this.Repository.GetCategories().AsQueryable<Category>();

What's the simplest way to get user Groups from WAAD?

爷,独闯天下 提交于 2020-01-24 23:40:25
问题 I've got AngularJS and Web.API WAAD authentication up and running. For client side I use great library ADAL.JS. For backend I use Microsoft.Owin.Security.OAuth. This part went quite smooth. Now I want to implement authorization based on roles (which will be mapped to WAAD groups). Groups are not included in authentication token so I must ask Azure Graph API for them. I saw various ways to do it, using custom claims providers, adding web services to project, etc. Some examples already