asp.net-web-api

Dapper multi-parameter stored procedure query returns nothing back from database

假装没事ソ 提交于 2020-02-05 03:54:11
问题 I have been using Dapper as my ORM for my .NET Core Web Api. When using Dapper to query a stored procedure from my database with one parameter, it works exactly as expected. When I add more than one parameter, it does not return anything back to my datamodel like it should. I suspect this has to do either with my syntax or the way I am structuring the query. The stored procedure I am using below works as expected when executed inside a SSMS query window. Here is my method containing the

Is it possible to expose multiple endpoints using the same WebAPI controller?

旧巷老猫 提交于 2020-02-04 05:33:07
问题 I want to create a WebAPI service for use in my single page application but I also want it to be available for a mobile application too. When users are using the SPA they are signed in using forms authentication and have a session cookie but if they're using the mobile application this wont be the case. Is it possible to expose the same API controller as 2 different endpoints where one is authenticated using mutual SSL, a token or as a last resort basic auth and the other uses the session

Web API 404 error Delete request

拜拜、爱过 提交于 2020-02-04 00:44:57
问题 I have a Web API that worked perfectly on development with all kind of HTTP requests (on the same controller), once I moved it to production (shared server, I don't even have access to it) the DELETE requests stopped working (the others are working fine), I get a 404 error: Requested URL https://www.example.com:443/ Rejected-By-UrlScan~ /API/Users/DeleteUser/1 Physical Path d:\xx\yy\example.com\Rejected-By-UrlScan Logon Method Anonymous Logon User Anonymous This is (a part of) the web.config:

Error on type WebActivatorEx.ActivationManager threw an exception …Parameter count mismatch

大兔子大兔子 提交于 2020-02-03 09:11:10
问题 I am getting this error after I installed Microsoft.Owin.*. Target .Net Framework:4.5.2. Web Activator: 2.2.0 I have the same setup in another project and that seems to work fine. Please help me debug or fix this. Have I have done so far:- Updated all Nuget Packages Deleted obj folder contents Ran aspnet_compiler.exe -p C:\source\Application\MyAPI -v anything -errorstack . It did give the same error, but stopped after I added WebMatrix.data. Full Error Details :- Parameter count mismatch.

Visual Studio for Mac azure remote debugging on Mac OS X

本小妞迷上赌 提交于 2020-02-03 05:49:25
问题 The matter is pretty simple: I'm on Visual Studio for Mac on Mac OS X Sierra , everything works perfectly and the deploy on Azure is great. The problem comes when I need to debug some odd error on the deployed remote app since it doesn't happen locally. I guess it's related to some third-party web service call but I really cannot figure out from the log. 来源: https://stackoverflow.com/questions/43991820/visual-studio-for-mac-azure-remote-debugging-on-mac-os-x

how to sanitize input data in web api using anti xss attack

女生的网名这么多〃 提交于 2020-02-03 04:47:05
问题 Below is the snippet of my code Model class // Customer.cs using CommonLayer; namespace Models { public class Customer { public int Id { get; set; } [MyAntiXss] public string Name { get; set; } } } I want to sanitize the value in the 'Name' field of the Model class as below // CutstomModelBinder.cs using Microsoft.Security.Application; using System.ComponentModel; using System.Linq; using System.Web.Mvc; namespace CommonLayer { public class CutstomModelBinder : DefaultModelBinder { protected

Passing body content when calling a Delete Web API method using System.Net.Http

别说谁变了你拦得住时间么 提交于 2020-02-03 04:34:05
问题 I have a scenario where I need to call my Web API Delete method constructed like the following: // DELETE: api/products/{id}/headers [HttpDelete("{id}/headers")] public void DeleteProductHeaders(int id, [FromBody] string query) { } The trick is that in order to get the query over I need to send it through the body and DeleteAsync does not have a param for json like post does. Does anyone know how I can do this using System.Net.Http client in c#? // Delete a product's headers public void

CsvHelper try to export in csv a list which contain another list .net

坚强是说给别人听的谎言 提交于 2020-02-02 12:55:09
问题 I implement a web api in .Net Framework using csvHelper to export a csv. I have the classes public class StudentInfo { public Student Student {get;set;} public Courses[] Courses { get; set; } } public class Student { public string Id {get;set;} public string Name{ get; set; } } public class Course { public string CourseId {get;set;} public string CourseName{ get; set; } } I have a method which return a List public List<StudentInfo> FetchStudentInfo() { //bla bla } Now I want to export in a

CsvHelper try to export in csv a list which contain another list .net

爱⌒轻易说出口 提交于 2020-02-02 12:54:07
问题 I implement a web api in .Net Framework using csvHelper to export a csv. I have the classes public class StudentInfo { public Student Student {get;set;} public Courses[] Courses { get; set; } } public class Student { public string Id {get;set;} public string Name{ get; set; } } public class Course { public string CourseId {get;set;} public string CourseName{ get; set; } } I have a method which return a List public List<StudentInfo> FetchStudentInfo() { //bla bla } Now I want to export in a

Can't make MVC4 WebApi include null fields in JSON

戏子无情 提交于 2020-02-02 02:37:29
问题 I'm trying to serialize objects as JSON with MVC4 WebAPI (RTM - just installed VS2012 RTM today but was having this problem yesterday in the RC) and I'd like for all nulls to be rendered in the JSON output. Like this: [{"Id": 1, "PropertyThatMightBeNull": null},{"Id":2, "PropertyThatMightBeNull": null}] But what Im getting is [{"Id":1},{"Id":2}] I've found this Q/A WebApi doesnt serialize null fields but the answer either doesn't work for me or I'm failing to grasp where to put the answer.