如何设置 IIS 来运行 HTML 表单的服务器代码?

发布于 2024-12-02 08:29:48 字数 108 浏览 5 评论 0原文

如果我有一个带有小表单的简单 html 页面,我想将其数据存储在服务器上的数据库中,那么我的服务器上需要什么才能接受表单输入?

我不想在 HTML 页面中使用任何 ASP.NET 代码。

If I have a simple html page with a small form whose data I'd like to store in a DB on the server, what do I need on my server to be able to accept the form input?

I'd rather not use any ASP.NET code in the HTML page.

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

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

发布评论

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

评论(2

揪着可爱 2024-12-09 08:29:48

正如我在评论中提到的,与 ASP.NET 中的 Java Servlet 最接近的是 IHttpHandler 的原始实现。您会注意到它具有以下约定:

bool IsReusable { get; };
void ProcessRequest(HttpContext context);

这与公开方法的 Java servlet 非常相似:

service(ServletRequest req, ServletResponse res);

不同之处在于,在 ProcessRequest 中,您将获取 context.Requestcontext.Response

最后,您需要在 web.xml 中注册您的处理程序。配置

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="/Url/Path/To/Your/Handler" type="SampleHandler, SampleHandlerAssembly" />
    </httpHandlers>
  </system.web>
</configuration>

As I mentioned in the comments, the closest thing to a Java Servlet in ASP.NET is a raw implementation of IHttpHandler. You'll note it has the following contract:

bool IsReusable { get; };
void ProcessRequest(HttpContext context);

This is very similar to a Java servlet which exposes the method:

service(ServletRequest req, ServletResponse res);

The difference being that in ProcessRequest you'll grab context.Request and context.Response.

Finally, you need to register your handler in the web.config:

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="/Url/Path/To/Your/Handler" type="SampleHandler, SampleHandlerAssembly" />
    </httpHandlers>
  </system.web>
</configuration>
顾北清歌寒 2024-12-09 08:29:48

您的 HTML 表单将数据提交到服务器。您将需要服务器上有一些东西来接受此数据并将其写入数据库。这可以是 ASP.NET 应用程序、PHP、Perl 或 Python 脚本,或者您可以在服务器上运行的任何其他内容。

您的 HTML 页面不一定必须具有任何 ASP.NET 代码,即使您的服务器端应用程序是用它构建的。

Your HTML form submits data to the server. You will need something on the server that accepts this data and writes it to your database. This could be an ASP.NET app, PHP, Perl or Python scripts, or just about anything else that you can get to run on your server.

Your HTML page doesn't necessarily have to have any ASP.NET code, even if your server-side application is built with it.

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