asp.net-web-api2

    0熱度

    1回答

    這是我的ApiController代碼。 // POST: api/SecurityApi [ResponseType(typeof(User))] public IHttpActionResult PostUser([FromUri] GeneralViewModel model) { if (model == null) {

    0熱度

    2回答

    背景 最近我改變了工作,並附加到一個Web API項目。我熟悉Web API & MVC的概念,但沒有事先親身經歷過。 我跟着幾個教程,並基於他們通過Visual Studio 2017創建了一個空的WebApi項目,從數據庫連接我的模型並添加了控制器。 這是修改後的控制器: private MyEntities db = new MyEntities(); //... [Re

    1熱度

    1回答

    我想在週末拒絕某些Web方法的輸入。行動過濾器看起來就像是自然的車輛。 public class RunMonThruFriAttribute : ActionFilterAttribute { public override void OnActionExecuting(HttpActionContext actionContext) { var today =

    0熱度

    2回答

    我試圖從Microsoft Web API 2控制器下載csv文件。這是我到目前爲止有: - 的Web API: - [Route("extractContent/{extractId}")] public async Task<IHttpActionResult> GetExtractContent(int extractId) { _logger.Info($"

    0熱度

    1回答

    我正在學習Angular 2並試圖讓它在ASP MVC設置上運行。我遵循這個非常優秀的指南:https://www.codeproject.com/Articles/1181888/Angular-in-ASP-NET-MVC-Web-API-Part 我修改它非常輕微。原本應該處理通過API端點api/userapi從數據庫中獲取的名稱列表。我改變了它,以便它成爲來自端點api/postapi的

    0熱度

    1回答

    我已經使用MySQL數據庫在visual studio 2015中創建了一個API。我有兩種GET方法。一個獲取所有記錄,另一個通過ID獲取記錄。第一種方法是完美的,但第二種方法引發了一個例外。 {"Message":"An error has occurred.","ExceptionMessage":"The format of value '\r\n' is invalid.","Excep

    0熱度

    1回答

    我使用MySQL DB在visual studio 2015中創建了WEB API。我有三個GET方法。一個是給出所有數據,第二個是給出基於ID的結果,第三個是根據序列號給出結果。前兩種方法是完美的,但最後一種不是。我還在解決方案中添加了多個路由。下面是我的代碼 WebApiConfig config.Routes.MapHttpRoute( name: "DefaultApi",

    0熱度

    1回答

    在我的webapi應用程序中,我想在特定時間安排行動。這裏是我的代碼: private readonly ConcurrentDictionary<string, Timer> timers; public void Schedule(TimeSpan when, Action<ElapsedEventArgs, Item> expiredCallback, Item item)

    0熱度

    2回答

    我試圖與實體框架簡單的原始查詢寫信給我的數據庫: [ResponseType(typeof(Customer))] [Route("name/{name}")] [HttpGet] public List<Customer> GetCustomerName(string name) { //var results = db.Customers.SqlQuery("SELECT N

    0熱度

    2回答

    如何配置webapi以允許不在模型中且應該忽略的額外屬性?目前序列化失敗它有額外的屬性,但缺少(不需要)屬性的工作。我們需要這個來讓api更強大。 示例中的WebAPI型號: public class User { [Key] public int Id { get; set; } public string Name { get; set; } } 但我們發