asp.net-web-api

Autofac register assembly types

南楼画角 提交于 2020-05-09 20:34:37
问题 In Castle, I used to do the following to register types from a different assembly: Classes.FromAssemblyNamed("MyServer.DAL") .Where(type => type.Name.EndsWith("Repository")) .WithServiceAllInterfaces() .LifestylePerWebRequest(), In Autofac, I change the above code to this: builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()) .Where(t => t.Name.EndsWith("Repository")) .InstancePerRequest(); Is it correct? 回答1: This is the correct way: builder.RegisterAssemblyTypes(AppDomain

swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B

馋奶兔 提交于 2020-05-09 20:02:10
问题 Using Web API and using swashbuckle to generate swagger documentation, I defined two different classes with the same name in two different namespaces. when I open swagger page in my browser it says Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround full message: 500 : {"Message":"An error has occurred.","ExceptionMessage":"Conflicting schemaIds: Duplicate schemaIds detected for types A and B.

RoutePrefix vs Route

♀尐吖头ヾ 提交于 2020-05-09 19:28:25
问题 I understand that RoutePrefix doesn't add a route to the routing table by itself. On your actions you need to have a Route attribute declared. I am having a hard time finding an authoritative blog/msdn page/ something that states why by defalut RoutePrefix doesn't add a route to the routing table. Does anyone have an authoritative post that does contain this to be the case, and if so will you let me know whom it is. Thank you very much. Edit To Clarify my question DOESN'T WORK [RoutePrefix(

RoutePrefix vs Route

梦想与她 提交于 2020-05-09 19:28:14
问题 I understand that RoutePrefix doesn't add a route to the routing table by itself. On your actions you need to have a Route attribute declared. I am having a hard time finding an authoritative blog/msdn page/ something that states why by defalut RoutePrefix doesn't add a route to the routing table. Does anyone have an authoritative post that does contain this to be the case, and if so will you let me know whom it is. Thank you very much. Edit To Clarify my question DOESN'T WORK [RoutePrefix(

Automatically generate TypeScript client code for ASP.NET Core controllers

放肆的年华 提交于 2020-05-09 17:59:41
问题 I'm searching for a way to automatically generate the TypesScript client code from a ASP.NET Core Web-Application (Currently using Visual Studio 2017RC and webpack). Are there any existing tools to generate the TypeScript client either in the build pipeline from visual studio or with webpack? I tried to use swagger middleware and then generate to client from the swagger URL, but I'm not sure if the intermediate swagger generation is the right tool for the job. Also the disconnectedness from

Swagger different classes in different namespaces with same name don't work

北城余情 提交于 2020-05-09 06:17:41
问题 I got (more than) two Api POST endpoints . Each one needs a json as parameter. But when I use the same class name Payload in two endpoint argument classes, Swagger does not work . When I change one of it e.g. from Payload to Payload1 than it works. Of course I set the right namespaces into the wrapper classes so it finds it Payload. But I would love to use the same name "Payload" each time. How can I use the same class name Payload ? I can keep the json name "Payload" at both cases and just

Swagger different classes in different namespaces with same name don't work

*爱你&永不变心* 提交于 2020-05-09 06:17:15
问题 I got (more than) two Api POST endpoints . Each one needs a json as parameter. But when I use the same class name Payload in two endpoint argument classes, Swagger does not work . When I change one of it e.g. from Payload to Payload1 than it works. Of course I set the right namespaces into the wrapper classes so it finds it Payload. But I would love to use the same name "Payload" each time. How can I use the same class name Payload ? I can keep the json name "Payload" at both cases and just

“Object reference not set to an instance of an object” when creating a new Web API controller with EF Scaffolding in Visual Studio 2012

旧时模样 提交于 2020-05-09 05:07:09
问题 I have an MVC4/Web API project, with an Entity Framework, Code First data model. When I try to create a new API Controller with read/write methods using a data context & model, I get an alert saying "Object reference not set to an instance of an object". I've done a bit of searching and found that some causes are incorrect project type Guids in the .csproj file, incomplete installation of the MvcScaffolding nuget package and one suggestion of installing Powershell 3. I have made sure all my

json.net limit maxdepth when serializing

混江龙づ霸主 提交于 2020-05-09 02:09:07
问题 We're using Asp.Net WebAPI with Entity Framework (with lazy loading) and using Json.net for serializing the data to json before returning the data to the client. We are experiencing intermittent sudden spikes in memory usage which we suspect might originate with json.net not recognizing reference loops when serializing data (since Entity Framework might be doing some lazy loading voodoo with proxy classes which goes under the radar of json.net) I thought I'd limit how deep Json.net was

json.net limit maxdepth when serializing

China☆狼群 提交于 2020-05-09 02:08:10
问题 We're using Asp.Net WebAPI with Entity Framework (with lazy loading) and using Json.net for serializing the data to json before returning the data to the client. We are experiencing intermittent sudden spikes in memory usage which we suspect might originate with json.net not recognizing reference loops when serializing data (since Entity Framework might be doing some lazy loading voodoo with proxy classes which goes under the radar of json.net) I thought I'd limit how deep Json.net was