调用Web服务时会出现异常“请求失败并显示HTTP状态401:未授权” [英] While calling Web service gets exception "The request failed with HTTP status 401: Unauthorized"

查看:432
本文介绍了调用Web服务时会出现异常“请求失败并显示HTTP状态401:未授权”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了一个ASP.NET Web服务,该服务托管在默认的visual studio
服务器上,并且在运行时支持Web服务。 exe文件反过来更新xml文件。

I created a ASP.NET web service, which was hosted on default visual studio
server, and on excecution of webservice it run .exe file which in turn update xml file.

现在我在IIS 6.0服务器上托管了这个web服务,当我运行服务时,它无法执行exe。
代码...

公共字符串HelloWorld()
    ; {
       处理myProcess = new Process();
       尝试
        {
            myProcess.StartInfo.UseShellExecute = false;
            //您可以开始任何流程,             myProcess.StartInfo.FileName = @" E:\Projects\some.exe" ;;            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
            myProcess.Close();
            myProcess.Dispose();
           返回"Suceess";

Now i hosted this webservice on IIS 6.0 server, and when i run the service, it
fails to execute the exe.
When i run it on debug mode, i never get any exception.

Code...

public string HelloWorld()
    {
        Process myProcess = new Process();
        try
        {
            myProcess.StartInfo.UseShellExecute = false;
            // You can start any process,             myProcess.StartInfo.FileName = @"E:\Projects\some.exe";
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
            myProcess.Close();
            myProcess.Dispose();
            return "Suceess";

        }
        catch(例外e)
        {
            Console.WriteLine(e.Message);
           返回"失败";        }
    }

        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            return "Failure";
        }
    }

注意:在通过aspx页面运行服务时,我得到"请求失败,HTTP状态为401:未经授权"
是否有一些许可问题?

Note: While runing service through aspx page, i get "The request failed with HTTP status 401: Unauthorized"
Is it some permission issue?

请帮助我。


提前致谢

推荐答案


 将用户身份验证模式设置为Windows并使其成为"匿名"模式IIS中的特定网站。

 这将有效,
Hi,
 Set the User Authentication mode to Windows and make it "Anonymous" for the particular web site in IIS.

 THis will work,


这篇关于调用Web服务时会出现异常“请求失败并显示HTTP状态401:未授权”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆