csharp 来自http://www.codemag.com/Article/1312081

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 来自http://www.codemag.com/Article/1312081相关的知识,希望对你有一定的参考价值。

public class CustomerController : ApiController
{
    [HttpGet]
    public HttpResponseMessage Customer(int id = 0)
    {
        var customer = new Customer()
        {
            Id = id,
            Name = "Jimmy Roe",
            Address = "123 Nowhere Lane\r\nAnytown, USA",
            Email = "jroe@doeboy.com"
        };
      
        string accept = Request.Headers
                                .GetValues("Accept")
                                .FirstOrDefault();
      
        if (!string.IsNullOrEmpty(accept) &&
            accept.ToLower().Contains("text/html"))
        {
            var html = ViewRenderer
                        .RenderView(
                              "~/views/samples/customerapi.cshtml",
                              customer);
            var message=new HttpResponseMessage(HttpStatusCode.OK);
            message.Content =new StringContent(html, Encoding.UTF8,
                                                "text/html");
            return message;
        }
      
        return Request.CreateResponse<Customer>(HttpStatusCode.OK,
                                                customer);
    }
      
}

以上是关于csharp 来自http://www.codemag.com/Article/1312081的主要内容,如果未能解决你的问题,请参考以下文章

csharp 来自csvj的getFrameworkVersion在tfvc上

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp HMACSHA256来自http://ideone.com/JdpeL