【问题标题】:Trying to Post from Browser, Method not allowed尝试从浏览器发布,方法不允许
【发布时间】:2017-05-01 18:24:39
【问题描述】:

我正在尝试将新数据添加到我的数据库中,我正在使用 wcf。

这是我的 iServiceRequest.cs

[OperationContract]
        [WebInvoke(Method = "POST",
              RequestFormat = WebMessageFormat.Json,
              ResponseFormat = WebMessageFormat.Json,
              UriTemplate = "/InsertData?ticket={ticket}&request={request}&category={category}&subCategory={subCategory}&subject={subject}&body={body}&assignto={assignto}&status={status}&fileName={fileName}&fileContent={fileContent}&fileBinary={fileBinary}&IsActive={IsActive}&createdBy={createdBy}&ACNo={ACNo}")]
        IEnumerable<USP_INSERT_DATA_Result> InsertData(string ticket, string request, string category, string subCategory, string subject, string body, string assignto, int status, string fileName, string fileContent, byte[] fileBinary, bool IsActive, string createdBy, int ACNo);

当我尝试使用浏览器发帖时

http://localhost:51458/ServiceRequest.svc/InsertData?ticket=ticket&amp;request=request&amp;category=categor&amp;subCategory=subCategory&amp;subject=subject&amp;body=body&amp;assignto=assignto&amp;status=1&amp;fileName=fileName&amp;fileContent=fileContent&amp;fileBinary=13213&amp;IsActive=1&amp;createdBy=createdBy&amp;ACNo=111

我正在获取服务方法是不允许的,你可以在下面的图片中看到它

Image Result

提前致谢

【问题讨论】:

    标签: angularjs json asp.net-mvc


    【解决方案1】:

    浏览器总是会发出获取请求。 使用邮递员或 Telerik fiddler 来发帖。

    如果您传递查询字符串中的所有值,那么您可以使用简单的 GET。

    【讨论】:

    • 但是我有新的错误,我可以在这里问吗?这是我的错误The server encountered an error processing the request. The exception message is 'Invalid length for a Base-64 char array or string.'. 你知道该怎么做吗?
    • @Randy,听起来你发布了错误的数据。我建议您发布一个新问题,并提供您发布的数据,因为它与此问题中提出的问题不同。
    • 谢谢。请使用您的服务方法发布一个新问题
    • 感谢您的建议,好的,接下来我将创建一个新的@Adrian
    • 是的,这是个好主意,它会让每个人都能识别我的问题@KalyanaSundaram
    猜你喜欢
    • 1970-01-01
    • 2015-11-25
    • 2018-08-22
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 1970-01-01
    • 2010-10-10
    相关资源
    最近更新 更多