Tag: rest

ASP.NET Web API MVC 4中具有特殊字符的自定义参数名称

我需要创建一个Get方法,该方法在URL中采用以下参数名称: ms-scale ms-contrast ms-lang 正如您所看到的,所有名称都有一个破折号,这在C#中是不可能的。 如何将我的方法映射到这些参数名称? public HttpResponseMessage Get(int scale, string contrast string lang)

什么是REST?

可能重复: 我对REST的理解是什么? 什么是REST? 它与WCF有什么关系? 我被要求研究RESTful服务的实现。 能否请您指出对初学者有帮助的链接。 我是一名具有良好ASP.NET知识的.NET开发人员

WCF REST服务JSON发布数据

寻找有关wcf 4rest服务的一些指导,该服务基于VS2010中的WCF REST模板40(CS)扩展。 我花了最近几天试图让这个bug工作,审查其他post,而我已经接近,我似乎无法越过终点线。 经过多次挫折之后,终于点击了服务并发布了(使用fiddler请求构建器),但是方法参数是空的,但它在请求构建器中正确设置。 我猜这可能是配置问题,但随着截止日期的临近,我没有时间进行更多的研究。 FWIW,在调试中,jsonstring变量为null。 自我肯定是一个noob问题,因为这是第一次通过REST为我,任何帮助将不胜感激! 提前致谢。 web.config中 ‘ 的global.asax.cs public class Global : HttpApplication { void Application_Start(object sender, EventArgs e) { RegisterRoutes(); } private void RegisterRoutes() { RouteTable.Routes.Add(new ServiceRoute(“Scoring”, new WebServiceHostFactory(), typeof(ScoringSvc))); } } 服务代码 [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class ScoringSvc { [OperationContract] [WebInvoke (Method = “POST”, BodyStyle […]

我应该如何在Windows Phone 7上使用RestSharp实现ExecuteAsync?

我正在尝试使用RestSharp GitHub wiki上的文档来实现对我的REST API服务的调用,但特别是我遇到了ExecuteAsync方法的问题。 目前我的代码对于API类来说是这样的: public class HarooApi { const string BaseUrl = “https://domain.here”; readonly string _accountSid; readonly string _secretKey; public HarooApi(string accountSid, string secretKey) { _accountSid = accountSid; _secretKey = secretKey; } public T Execute(RestRequest request) where T : new() { var client = new RestClient(); client.BaseUrl = BaseUrl; client.Authenticator = new HttpBasicAuthenticator(_accountSid, _secretKey); […]

RESTful WCF服务图像上传问题

1 namespace Uploader 2 { 3 using System; 4 using System.IO; 5 using System.ServiceModel; 6 using System.ServiceModel.Description; 7 using System.ServiceModel.Web; 8 using System.Drawing; 9 using System.Drawing.Imaging; 10 using System.Net; 11 using System.Xml; 12 13 [ServiceContract(Namespace = “http://Uploader”)] 14 public interface IUploaderService 15 { 16 [OperationContract, WebInvoke(Method = “POST”,UriTemplate = “File/{fileName}”)] 17 bool UploadFile(string fileName, Stream […]

C# – 如何使用C#查找纬度和经度

我在C#中有一个WCF服务。 在服务呼叫客户端中发送城市名称。 我想将城市名称转换为纬度和经度,并在人口统计数据下存储在数据库中。 我打算使用Google API来实现上述function。 我从Google及其“服务帐户”类型获得了一个API密钥。 如何使用哪些API获取经度和纬度? 我是否需要安装某些SDK或任何REST服务?

为什么我的文件没有被我的Web API函数的GET请求返回?

我有一个函数可以通过我的REST API访问,配置ASP.NET Web API 2.1,应该将图像返回给调用者。 出于测试目的,我只是让它返回我现在存储在本地计算机上的示例图像。 这是方法: public IHttpActionResult GetImage() { FileStream fileStream = new FileStream(“C:/img/hello.jpg”, FileMode.Open); HttpContent content = new StreamContent(fileStream); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(“image/jpeg”); content.Headers.ContentLength = fileStream.Length; return Ok(content); } 调用此方法时,我根本无法获取图像。 以下是我收到的回复: { “接头”:[{ “密钥”: “内容类型”, “值”:[ “图像/ JPEG”]},{ “密钥”: “内容长度”, “值”:[ “30399”] }]} 为什么我没有将图像数据作为请求的一部分返回? 怎么解决这个问题?

无法将REST API用于Windows Server 1.1的Service Bus(OnPremises)

我正在使用Window Server Service Bus 1.1。 我能够使用以下基址从Window Server Service Bus生成OAuth令牌 string baseAddressHttp = “https://” + ServerName + “:9355/” + Namespace + “/$STS/OAuth/”; 对于用于将消息发送到队列的Window Azure Service Bus,我可以在以下队列地址上发出请求 string serviceNamespace = “ServiceBusDefaultNamespace”; string queueName = “SampleQueuName”; string message =”This is my first message”; string queueAddress = “https://” + serviceNamespace + “.servicebus.windows.net/”+ queueName + “/messages”; WebClient webClient = new […]

Unity 3D放置/删除http方法

我正在考虑将一个JavaScript Web应用程序移植到C#Unity3D(免费/个人版),用于我正在开发的RPG。 我有一个用PHP Laravel 5.1构建的可扩展,独立的API,我的游戏通过jQuery http调用进行交互。 我需要继续在Unity中进行标准的restful调用, get , post , put , delete等,但只发现了UnityEngine.WWW# ,这使得gets和posts 。 这个SO Post共享其他可用的Unity3D http方法,但没有一个实际上将所有的restful调用放在一个。 我再次问,因为这是在2012年发布的,我没有在更新的文档中找到任何满足此要求的更新 。 有45美元和55美元的最佳HTTP基础和最佳HTTP ,但我们认为会有其他免费选项。 我是否遗漏了Unity中允许标准的rest呼叫的内容?

从ASP.NET 5控制器VS 2015获取wwwroot文件夹路径

很抱歉有一个noob问题,但似乎我无法从Controller获取Server.MapPath。 我需要从wwwroot的images文件夹输出json文件列表。 他们是在wwwroot / images。 我怎样才能获得可靠的wwwroot路径? using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Mvc; using www.Classes; using System.Web; namespace www.Controllers { [Route(“api/[controller]”)] public class ProductsController : Controller { [HttpGet] public IEnumerable Get() { FolderScanner scanner = new FolderScanner(Server.MapPath(“/”)); return scanner.scan(); } } } System.MapPath似乎在System.Web命名空间中不可用。 Project正在使用ASP.NET 5和dotNET 4.6 Framework