服务器上而非本地的 ASP.NET Web 服务解析器错误

发布于 2024-12-10 04:16:50 字数 1954 浏览 0 评论 0原文

EDIT2

看起来我无法正确阅读,请忽略这篇文章,我将尝试制作 WCF 服务。

谢谢

编辑:

好吧,看来我应该开始学习 MVC。当我无法让它工作时,我之前尝试过进入它,但也许我没有足够努力,因为我已经完成了我的网络服务,并且在我知道问题是否微不足道之前不想重新开始。

对于那些感兴趣的人:

我实际上想要完成的是创建一个包含十几个不同高分表的数据库,我将能够从我的 Android 应用程序中以 JSON 形式检索这些表。到目前为止,我有一个 XML 数据库和一个 web 方法,用于询问分数是否在特定高分表上的前 50 名。一种用于提交您的分数,另一种用于检索整个高分以在应用程序中显示。我还有一个简单的界面,用于从数据库中添加、删除等。

更新的问题: 如果我创建一个 MVC 项目,我是否能够重用我的一些代码以及如何将所述项目放在服务器上?可以使用 FTP 客户端来完成还是需要使用 Web Deploy、IIS 或 Web Matrix 或其他软件?服务器有什么要求?

非常感谢您的帮助:)

----------原帖----------------

最近我一直在尝试学习如何在 Microsoft Visual Web Developer(win7 64 位上的 2010 Express)中的 Web 应用程序中创建 Web 服务。我有一些非常简单的 JSON Web 方法,当我从 Visual Web Developer 本地运行该项目时,它就像一个魅力,它们返回正确的值等。

但是当我将项目传输到运行 .NET 4.0 的 Windows 服务器时(这是与本项目中的目标框架相同)我无法再访问 Web 服务,.aspx 网页运行良好,但 .asmx Web 服务显示以下内容错误:(

我只能发布两个超链接所以我删除了这个图像)

顺便说一句,第 1 行是 .asmx 文件中的唯一行。我尝试将 Namespace.Classname 放在那里,但错误仍然存​​在。 (Test.DBWebService 而不仅仅是 DBWebService)

我没有更改代码中的任何内容,这个确切的代码确实可以在我的计算机上运行。我尝试过一些可以帮助其他人解决类似问题的方法,例如构建选项:

运行启动页面之前:构建网站

目标框架:.NET 4.0

构建网站作为框架的一部分检查了

我认为应该这样配置。

我的 web.config 如下所示:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation targetFramework="4.0"/>
    <customErrors mode="Off"/>
  </system.web>
  <appSettings>
  </appSettings>
  <system.serviceModel>
    <bindings/>
    <client/>
  </system.serviceModel>
</configuration>

这是 Web 服务的 .cs 文件,也是一个可以在本地工作但无法在服务器上访问的示例方法。

https://i.sstatic.net/4T6pq.png

什么可能会导致此问题?我是否在这里错过了一些重要的东西,因为我经验不足。我已经尝试了好几天来完成这项工作,甚至询问了我的网络托管公司,但他们说他们不帮助解决与编程相关的问题。

EDIT2

Looks like I can't read properly, disregard this post, I will try to make a WCF service instead.

Thank you

EDIT:

Ok it seems I should start learning MVC instead. I tried getting into it before when I could't get this to work but maybe I didn't try hard enough because I already completed my web services and didn't feel like starting over before I knew if the problem was trivial.

For those who are interested:

What I am actually trying to accomplish is to create a database with a dozen different highscore tables which I will be able to retrieve from my Android app as JSON. So far I have an XML database and a webmethod for asking if a score is in the top 50 on a specific highscore table. One for submitting your score, and one for retrieving the entire highscore to show in the app. I also have a simple interface for adding, removing etc from the database.

Updated question: Will I be able to reuse some of my code if I create an MVC project and how do I put said project on the server? can it be done with an FTP client or do I need to use Web Deploy, IIS or web matrix or some other software? and what are the requirements of the server?

Thank you so much for the help :)

----------Original Post--------------

Recently I have been trying to learn how to create a web service in Microsoft Visual Web Developer (2010 express on win7 64bit) in a web application. I have a few very simple JSON web methods and when I run the project locally from Visual Web Developer it works like a charm, they return the correct values etc.

But when I transfer the project to my windows server running .NET 4.0 (which is the same as my target framework in this project) I can't access the web service anymore, the .aspx web pages work great but the .asmx web service shows the following error:

(I can only post two hyperlinks yet so I removed this image)

That line 1 is the only line in the .asmx file btw. I have tried putting the Namespace.Classname there instead but the error remains. (Test.DBWebService instead of just DBWebService)

I haven't changed anything in the code, this exact code does work on my computer. I have tried things that helped others with similar issues, like the build options:

Before running startup page: Build Web Site

Target Framework: .NET 4.0

Build Web Site as part of a framework Checked

which I assume should be configured like that.

My web.config looks like this:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation targetFramework="4.0"/>
    <customErrors mode="Off"/>
  </system.web>
  <appSettings>
  </appSettings>
  <system.serviceModel>
    <bindings/>
    <client/>
  </system.serviceModel>
</configuration>

This is the .cs file for the web service and an example method which works locally but can't be accessed on the server.

https://i.sstatic.net/4T6pq.png

What could possible create this problem? Am I missing something vital here because I am not very experienced. I have tried for days to get this done and even asked my web hosting company but they said they don't help with programming related issues.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绻影浮沉 2024-12-17 04:16:51

导致您的问题的最可能原因是:
- IIS 中站点(应用程序)的配置错误。我的猜测是,您正在部署到应用程序上,但由于某种原因,应用程序未正确创建,并且 ASP.NET 无法初始化二进制文件应存在的 /bin 文件夹
- IIS/ASP.NET 配置错误。找到另一台具有类似配置的机器并检查那里的站点。如果工作正常,您可以返回并尝试查找/解决本地 ASP.NET 配置的问题。

Most probable causes of your issue are:
- wrong configuration of the site (application) within the IIS. My guess is that you are deploying onto an application but for some reason the application is not correctly created and the ASP.NET is unable to initialize the /bin folder where the binaries should exist
- wrong configuration of the IIS/ASP.NET. Find another machine with similar configuration and check your site there. If it works correctly, you could go back and try to find/resolve issues with your local ASP.NET configuration.

§普罗旺斯的薰衣草 2024-12-17 04:16:50

如果您刚刚学习 Web 服务,那么您应该立即停止。你犯了一个重大错误。

您正在使用“ASMX Web 服务”,这是一种几乎已经过时的技术。除非别无选择,否则不应使用 ASMX 进行新开发。

您犯的另一个错误是使用网站“项目”。我强烈建议您不要将它们用于除简单网站之外的任何其他用途,并且您可能希望在任何情况下都避免将它们用于此目的。除此之外,他们有一个确切的问题,就是当你认为他们应该构建的时候却没有构建你认为他们应该构建的东西。

请改用 Web 应用程序项目,使用“添加新项目”而不是“添加新网站”。

If you are just now learning web services, then you should stop right now. You've made a major mistake.

You are using "ASMX Web Services", a technology which is all but obsolete. No new development should be done using ASMX unless there is no other choice.

Another mistake you are making is in using the web site "project". I strongly recommend you not use those for anything other than simple sites, and you might want to avoid them for that purpose in any case. Among other things, they have this precise issue with not building what you think they should build when you think they should build it.

Use a web application project instead, using "Add New Project" instead of "Add New Web Site".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文