将aspx页面转换为链接?

时间:2011-10-19 06:23:52

标签: c# asp.net http

我在XAML中有以下内容:

<Setter Property="Source" Value="ResourceHttpHandler.aspx" />

我想在HTTP处理程序中执行的操作是发送回徽标的链接(例如url.com/abc.png),并将ResourceHttpHandler.aspx替换为该徽标的链接。

这是我目前的尝试:

  public void ProcessRequest( HttpContext _HttpContext )
  {
     try
     {
        HttpRequest request = _HttpContext.Request;
        HttpResponse response = _HttpContext.Response;
        response.ContentType = MimeTypes.TextHTML;
        response.Cache.SetExpires( DateTime.Now );
        response.AppendHeader( "Content-Disposition", MimeDispositions.Inline );

        if( request.HttpMethod == WebRequestMethods.Http.Get )
        {
           response.Write("http://www.google.com/intl/en_com/images/srpr/logo3w.png");
           response.Flush();
        }
     }
     catch( Exception e )
     {
        _HttpContext.Response.Clear( );
        _HttpContext.Response.Write( HttpResponseString.CreateError( e.Message ) );
        _HttpContext.Response.Flush( );
     }
  }

我该怎么做?

1 个答案:

答案 0 :(得分:2)

也许简单地重定向可以解决您的问题。

Response.Redirect("http://www.google.com/intl/en_com/images/srpr/logo3w.png");