在 asp.net 中添加我自己的页面扩展

发布于 2024-08-24 07:35:54 字数 183 浏览 3 评论 0原文

我正在尝试添加带有自定义扩展名的页面,例如带有我的一组 html 标签的 .asp2。 现在,每当我尝试访问浏览器上的页面时...它都会询问我“另存为”。发生这种情况是因为我使用了服务器无法识别的扩展。 我应该怎么做才能让我的服务器 IIS 5.1 识别这个扩展?

请建议

还请建议如何在此类自定义页面上关联自定义事件?

I am trying to add page with custom extension, say .asp2 with my set of html tags.
Now whenever i try to access the page on browser...it asks me "Save as". This happens because I am using an extn which the server is not able to recognise.
What should I do to so that my server, IIS 5.1 recognises this extension??

Please suggest

Also please suggest on how to associate custom events on such custom page?

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

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

发布评论

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

评论(2

呢古 2024-08-31 07:35:54

在 Internet 服务管理器中,右键单击“默认网站”,选择“属性”,在“主目录”中按“配置”按钮。单击“添加”按钮,然后在“可执行文件”字段中填写 aspnet_isapi.dll 文件的路径,并将 asp2 放入“扩展名”字段中。

In Internet Services Manager, right click on Default Web Site, select Properties, in Home Directory press the Configuration button. Click the Add button and fill the Executable field with the path to the aspnet_isapi.dll file and put asp2 in the Extension field.

伴我老 2024-08-31 07:35:54

使用非标准扩展,您还应该确保将响应的内容类型设置为 text/html,以便浏览器知道如何解释您发送的文档。像这样的东西:

public class HttpHandler1 : IHttpHandler
{
  public bool IsReusable
  {
    get { return true; }
  }

  public void ProcessRequest(HttpContext context)
  {
    context.Response.ContentType = "text/html";

    // Your code here.
  }
}

Using a non-standard extension, you should also be sure to set the response's Content Type to text/html, so the browser knows how to interpret the document you're sending. Something like:

public class HttpHandler1 : IHttpHandler
{
  public bool IsReusable
  {
    get { return true; }
  }

  public void ProcessRequest(HttpContext context)
  {
    context.Response.ContentType = "text/html";

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