【问题标题】:C# create temporary url to receive HTTP requestC# 创建临时 url 来接收 HTTP 请求
【发布时间】:2012-08-30 10:46:19
【问题描述】:

嗨,我是 C# 和网站设计的新手。我正在开发一个控制台应用程序,它将临时创建一个有效的 URL 并在短时间内接收 HTTP 请求。有人可以帮忙吗?

【问题讨论】:

  • 我不知道你是想编写一个创建像http://www.stackoverflow.com 这样的字符串、发出请求并捕获响应的客户端,还是一个接受请求的服务器,例如为ftp://www.mytest.disorg 做点什么。很短的时间。
  • 您可以创建一个简单的 WCF 客户端,并在临时端点上动态托管,接收您需要接收的内容,然后关闭/重新开始。一个简单的例子(用http替换net.tcp)weblogs.asp.net/ralfw/archive/2007/04/14/…

标签: c# asp.net http web-applications web


【解决方案1】:

如果我理解正确,您只需拨打RewritePath 即可拨打任何电话。这可以在 global.asax 上完成:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    // Any call, eg WhatEverName.aspx -> it will call the ExistingFile.aspx
    HttpContext.Current.RewritePath("ExistingFile.aspx");
}

【讨论】:

    猜你喜欢
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 2023-02-13
    相关资源
    最近更新 更多