title: How can I redirect/return an aspx page from a controller action?
body: <p>How Can I return a particular aspx page wiht the path from a controller action?</p>
  
  <p>Here is how I redirect from a controller action:</p>
  
  <pre><code>Response.Redirect("_PDFLoader.aspx?Path=" + FilePath  +  id + ".pdf");
  </code></pre>
  
  <p>Even tried the following:</p>
  
  <pre><code>return Redirect("_PDFLoader.aspx?Path=" + FilePath + id + ".pdf");
  </code></pre>
  
  <p>Here is my _PDFLOader.aspx page:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="_PDFLoader.aspx.cs" Inherits="Proj._PDFLoader" %&gt;
  </code></pre>
  
  <p>Here is my CodeBehind file:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.IO;
  
  namespace Proj
  {
      public partial class _PDFLoader : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              string OutfilePath = Request.QueryString["Path"].ToString();
              FileStream objfilestream = new FileStream(OutfilePath, FileMode.Open, FileAccess.Read);
              int len = (int)objfilestream.Length;
              Byte[] documentcontents = new Byte[len];
              objfilestream.Read(documentcontents, 0, len);
              objfilestream.Close();
  
              if (File.Exists(OutfilePath)) File.Delete(OutfilePath);       
  
              Response.ContentType = "application/pdf";
              Response.AddHeader("content-length", documentcontents.Length.ToString());
              Response.BinaryWrite(documentcontents);
  
          }
      }
  }
  </code></pre>
  
  <p>Any help is much appreciated.</p>