How to avoid the Response.Redirect of the root request?http://forums.asp.net/t/1257722.aspx/1?How+to+avoid+the+Response+Redirect+of+the+root+request+Thu, 08 May 2008 02:39:12 -040012577222342287http://forums.asp.net/p/1257722/2342287.aspx/1?How+to+avoid+the+Response+Redirect+of+the+root+request+How to avoid the Response.Redirect of the root request? <p>&nbsp;Apologies if this has been covered before, but I can't find a reference to it. <br> <br> You can find this issue in any projects created by the MVC0416.<br> In the file &quot;Default.aspx.cs&quot; , there is a line of code looks like &quot;Response.Redirect(&quot;~/Home&quot;)&quot;, I know this is for processing the root request to the HomeController.<br> But the url was changed and almost every search engine isn't too fond of Response.Redirect.<br> That's the question.<br> <br> I tried wrote a route to avoid this, but it doesn't work.<br> the route is:<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; routes.MapRoute(<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Root&quot;,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Default.aspx&quot;,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new { controller = &quot;Home&quot;, action = &quot;Index&quot; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br> <br> When I request the root path, I got an empty page, and when I request the /default.aspx page, I got an XML parsing error.<br> In any projects created by the Preview 2 don't have this problem because of the last route configuration.<br> But it's not working in the new projects.<br> <br> That's all. I'm looking for a solution for this.<br> Thank you all very much.</p> 2008-05-07T07:28:16-04:002342440http://forums.asp.net/p/1257722/2342440.aspx/1?Re+How+to+avoid+the+Response+Redirect+of+the+root+request+Re: How to avoid the Response.Redirect of the root request? <p>&nbsp;</p> <p>hi, </p> <p>&nbsp; better to use &quot;Server.Transfer&quot;, for single server. it will avoid the unwanted process of searching and finding the destionation server(URL).</p> 2008-05-07T08:55:53-04:002342888http://forums.asp.net/p/1257722/2342888.aspx/1?Re+How+to+avoid+the+Response+Redirect+of+the+root+request+Re: How to avoid the Response.Redirect of the root request? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>shinyzhu</h4> In the file &quot;Default.aspx.cs&quot; , there is a line of code looks like &quot;Response.Redirect(&quot;~/Home&quot;)&quot;,</blockquote> <p></p> <p>You can do it as below:&nbsp;</p> <p>Step-1. Cooment the &quot;Response.Redirect(&quot;~/Home&quot;)&quot; code in the Default.aspx.cs page.</p> <p>Step-2. RightClick on SolutionExpolre --&gt; select &quot;Properties&quot; --&gt; Select Web tab --&gt; select &quot;Specific Page&quot; radiobutton --&gt; write &quot;Home&quot; in the textbox --&gt; save and run the application.</p> 2008-05-07T12:24:47-04:002343957http://forums.asp.net/p/1257722/2343957.aspx/1?Re+How+to+avoid+the+Response+Redirect+of+the+root+request+Re: How to avoid the Response.Redirect of the root request? <p>Here is an explanation of the issue from <a class="" title="haacked.com" href="http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx"> haacked.com</a></p> <p>&nbsp;</p> <p>&quot;The Dynamic Data Preview readme has the steps to update your MVC Preview 2 project to work with the new routing. Youll notice that the readme recommends having a Default.aspx file in the root which redirects to <em><em>/Home</em></em>. Technically, the Default.aspx file in the root wont be necessary in the final release because of the suggested routing changes (it is necessary now due to a minor bug). Unfortunately, Cassini doesnt work correctly when you make a request for &quot;/&quot; and there is no default document. It doesnt run any of the ASP.NET Modules. So we kept the file in the root, but you <strike>can</strike> will be able to remove it when deploying to IIS 7. So to recap this last point, <em>the Default.aspx in the project root is to make sure that Cassini works correctly. It's will not be needed for IIS 7 in the future, but is needed for the time being.&quot;</em></p> 2008-05-07T19:26:58-04:002344239http://forums.asp.net/p/1257722/2344239.aspx/1?Re+How+to+avoid+the+Response+Redirect+of+the+root+request+Re: How to avoid the Response.Redirect of the root request? <p>so will it ever be possible to hit an mvc site with <a href="http://www.domain.com/"> www.domain.com</a> without it redirecting to <a href="http://www.domain.com/controller"> www.domain.com/controller</a> ?&nbsp; </p> 2008-05-07T22:21:52-04:002344433http://forums.asp.net/p/1257722/2344433.aspx/1?Re+How+to+avoid+the+Response+Redirect+of+the+root+request+Re: How to avoid the Response.Redirect of the root request? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jgo23</h4> so will it ever be possible to hit an mvc site with <a href="http://www.domain.com/"> www.domain.com</a> without it redirecting to <a href="http://www.domain.com/controller"> www.domain.com/controller</a> ?&nbsp; </blockquote> <p></p> <p>Yes.&nbsp; You can set the <em>RouteExistingFiles</em> flag to true, as described in <a href="http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx"> http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx</a>.&nbsp; Alternatively, if you're using IIS7, you actually don't even need the Default.aspx file at all.&nbsp; Just delete it and everything should just work.</p> 2008-05-08T02:39:12-04:00