asp.net-web-api

Change Primary Key for Asp.net Identity and GetUserID<int>

六月ゝ 毕业季﹏ 提交于 2020-01-14 03:45:07
问题 I am creating a WebAPI (OData) project and have used Asp.Identity for my user management. I have read through Change Primary Key for Users in ASP.NET Identity and everything works as prescribed, I do not know how to configure the Bearer token. In Tom FitzMacken's example, he configures Cookie Authentication as follows. app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"),

Creating an API only for my own mobile apps. Do I need OAuth?

南笙酒味 提交于 2020-01-14 03:04:17
问题 I am about to create mobile applications (iOS, android, ..) to support existing web application and now thinking how to provide a secure API (ASP.Net Web API) from my web to our mobile apps. OAuth seems the best way to do it. From what I understand, it is designed to enable 3rd party applications written against our API. But I only use the web services just for my own apps. Do I need to go with OAuth, or is there any simple way? 回答1: There is a 2 legged version of OAuth that is designed for 2

Creating an API only for my own mobile apps. Do I need OAuth?

为君一笑 提交于 2020-01-14 03:03:35
问题 I am about to create mobile applications (iOS, android, ..) to support existing web application and now thinking how to provide a secure API (ASP.Net Web API) from my web to our mobile apps. OAuth seems the best way to do it. From what I understand, it is designed to enable 3rd party applications written against our API. But I only use the web services just for my own apps. Do I need to go with OAuth, or is there any simple way? 回答1: There is a 2 legged version of OAuth that is designed for 2

Error when Update-Database using Code-First: “There is already an object named 'something' in the database.”

霸气de小男生 提交于 2020-01-14 02:30:53
问题 I'm doing database migration using Code-First in Visual Studio 2015. Along the way, i've done the migration steps up till Add-Migration . After Add-Migration, i've added this line of code Database.SetInitializer(New MigrateDatabaseToLatestVersion(Of DbContext1, Migrations.Configuration)) in my DbContext constructor to set up Database Initializer since i missed this step previously. After that, i executed "Add-Migration initial -Force" in the Package Manager Console because i fear that this

Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format

眉间皱痕 提交于 2020-01-13 19:28:10
问题 I have an ASP.NET MVC 4 Web Api application with .NET Framework 4.0 and C# deployed on a Windows 7 Professional 64 bits and IIS 7.0. When I run the app, http://myHost/WebApi, I get this: Can not load file or assembly 'AutomationMiddleware.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format. Description: An unhandled exception when running the current web request. Review the stack trace for more information about the error and where it originated

How to use Breeze with Generic Unit of Work and Repositories?

£可爱£侵袭症+ 提交于 2020-01-13 17:02:31
问题 Using this: https://genericunitofworkandrepositories.codeplex.com/ and the following set of blog posts: http://blog.longle.net/2013/05/11/genericizing-the-unit-of-work-pattern-repository-pattern-with-entity-framework-in-mvc/ We are trying to use those repositories with Breeze since it handles client side javascript and OData very well. I was wondering how we could use these with Breeze to handle overriding the BeforeSaveEntity correctly. We have quite a bit of business logic that needs to

Is it possible to send values to controller from middleware in aspnet core api?

*爱你&永不变心* 提交于 2020-01-13 16:22:08
问题 I want to know if is it possible to send value from middleware to controllerAPI ? For example, I want catch one particular header and send to the controller. Something like that : public class UserTokenValidatorsMiddleware { private readonly RequestDelegate _next; //private IContactsRepository ContactsRepo { get; set; } public UserTokenValidatorsMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { if (!context.Request.Path.Value.Contains("auth"))

MVC Web API Binding Model to a Derived Class

本秂侑毒 提交于 2020-01-13 14:29:02
问题 I am looking at how to bind a model to a derived class within MVC Web API, the issue I have is that I think I have found about 5 ways of doing it... What I have is: Models -> ModelBase ModelA : ModelBase ModelB : ModelBase Controller then containers the method: Post(ModelBase model) {} The data that is posted will be ModelA or ModelB, I want to add information to the HTTP Request metadata (think Content-Type: application/json; type=ModelA) and based on this tell MVC to bind the posted content

Using IApplicationBuilder.Map generates nested paths with UseMvc

…衆ロ難τιáo~ 提交于 2020-01-13 10:34:08
问题 I'm trying the new asp.net 5 alongside VSNET 2015 RC. Configuration of my webapp: Microsoft.AspNet.Mvc 6.0.0-beta4 I'm really confused about this behavior: if i use public void Configure(IApplicationBuilder app, IHostingEnvironment env) { ... app.UseMvc(); } everything works. I call my controller via http://localhost:1234/api/values and all is ok. For the sake of my testing if i change the snippet above in public void Configure(IApplicationBuilder app, IHostingEnvironment env) { ... app.Map("

ASP.NET WebAPI Supported Media Types per Method

可紊 提交于 2020-01-13 10:21:49
问题 Given a method in a controller: public class CustomerController : ApiController { [HttpGet] public CustomerDto GetById([FromUri] int id) { . . return customerDto } } Is there a way to specify supported Media Types with an attribute? For instance, CustomerDto is a complex class and will only serialize with JSON (application/json) not XML (application/xml) but could also accept PDF (application/pdf). Is there something like this: [HttpGet(Accepts.JSON, Accepts.PDF)] or [HttpGet][AcceptJSON]