asp.net-web-api

MVC Web API posting JSON data gives me a 404

我的未来我决定 提交于 2019-12-31 04:07:28
问题 I have a Web API in MVC4. I'm getting a 404 when posting data using ajax and I don't understand why. LanguageController: [AcceptVerbs("POST")] public void Delete(string id) { Guid guid = Guid.Parse(id); Language language = db.Languages.Find(guid); db.Languages.Remove(language); db.SaveChanges(); } Routing: public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "DefaultActionApi", routeTemplate: "api/{controller}/{action}/

Response of Http Api call promise is undefined - Angular 2

杀马特。学长 韩版系。学妹 提交于 2019-12-31 04:01:07
问题 I have created an api in WebAPI as below. public HttpResponseMessage Get() { var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject("Hello World"), Encoding.UTF8, "application/json"); return response; } I am trying to call it from Angular as below Service.ts @Injectable() export class DemoService { constructor(private http:Http){} GetHttpData(){ return this.http.get('http://localhost:54037/api/home') .map((res:Response)=>res

Postman with miltiple params on Web Api C#

丶灬走出姿态 提交于 2019-12-31 03:48:09
问题 I'm having a problem with this technology, I already have created a entry in my web api controller that allows me to create users: public IHttpActionResult PostUser(User user) and I can consume this rest service with postman like this: Now I want to create a similar entry but this time with 2 parameters, like this: public IHttpActionResult PutUser(int id, User user) MY PROBLEM IS THAT I CAN'T REACH THIS METHOD WITH POSTMAN I already try: Add my "id" parameter on postman heather Add my "id"

How to use JWT for asp.net Core

跟風遠走 提交于 2019-12-31 03:43:09
问题 I follow JWT Authentication for Asp.Net Web Api answer to add JWT to my asp.net core project but System.Web.Http.Filters is not supported in .net core?? any better solution for securing web API ??? 回答1: Filters are supported in ASP.NET Core MVC. You can find them in Microsoft.AspNetCore.Mvc.Filters namespace. Take a look at this guide for example. Bear in mind that you don't need to implement JWT authentication filter yourself. This has already been implemented as part of Microsoft.AspNetCore

Rewrite rule for WebAPI fails because of ExtensionlessUrlHandler

有些话、适合烂在心里 提交于 2019-12-31 03:04:31
问题 I am attempting to use IIS to rewrite requests from my ASP.net MVC 4 application to my ASP.net MVC 4 WebApi. From the client, I am using ajax to make calls back to the server which I would then like the server to rewrite the request to point to the webapi site. This should solve any cross domain issues if I can get it to work. I have installed URL rewrite, Web Farm Framework, ARR, and External Cache per this article: http://blogs.iis.net/wonyoo/archive/2011/04/20/how-to-install-application

ASP.NET MVC WebApi & EF Lazy Loading = forever loading?

不想你离开。 提交于 2019-12-31 02:49:04
问题 In my ASP.NET MVC WebApi project I have a Repository (with an Interface) that queries the DB via a simple Linq SingleOrDefault command and then outputs everything to The Controller. (EF = Database first against Oracle DB) The Problem is that, when I turn on Lazy Loading (via the EDMX file property) the get is loading forever and there is no response. If I turn off Lazy Loading everything works fine? Even stranger ist that when I put all the query in a console app and output everything via

Different Models for RESTful GET and POST

旧街凉风 提交于 2019-12-31 02:26:06
问题 Does it violate the ideas of REST, or accepted conventions, to have different models for GET/PUT/POST at the same URL? An example: Consider a simple resource found at api/things I can create a thing by: POST api/things with body = { Name: "New Thing" } This returns me a thing along with location { Id: 500, Name: "New Thing", Links: ["api/things/500"] } Location Header: api/things/500 I can get the thing with: GET api/things/500 and I will get { Id: 500, Name: "New Thing", Links: ["api/things

Breezejs Double trouble in angularjs

痞子三分冷 提交于 2019-12-31 02:23:05
问题 I am trying to change a value in a angular view from a integer to a float/double value that is bind to ngmodel. The input don’t except anything other than a integer. My guess is that breeze does something in the background to validate the value or something on the "defined properties". But my knowledge of JavaScript prototyping is very limiting aka I need to learn it.. This is really hard to explain so I created a plunk that can hopefully help: http://plnkr.co/edit/Gcj0VvBE3f8DRbIjMtqt?p

Post values are not set because of special characters in Web API

夙愿已清 提交于 2019-12-31 01:54:15
问题 I'm trying to make a post to my web api service. The point is that while sending a message like { message: "it is done" } working fine. However when I use special characters like çıöpş in my message it is unable to convert my json so that the post object remains null. What can I do? It is either current culture issue or something else. I tried to send my post parameter as HtmlEncoded style with encoding HttpUtility class but it didn't work either. public class Animal{ public string Message

Git/SSH hanging when called from MVC WebApi

大憨熊 提交于 2019-12-31 01:48:27
问题 Part of a project I'm working on (Windows, C#, MVC4 WebAPI) requires some integration with git. None of the existing C# git libraries supported remote cloning, so I wound up porting the parts of the JavaGit project we needed (checkout, fetch, status), and writing clone myself. All it really is is a wrapper to the git command line executable. The relevant code it calls is here: public static void RunGitCommand(string repositoryPath, string gitArguments) { // GitCommand is the full path to git