开发者

How can I set up IIS to run server code for an HTML form?

开发者 https://www.devze.com 2023-04-01 02:24 出处:网络
If I hav开发者_运维知识库e 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?

If I hav开发者_运维知识库e 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.


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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号