Open Url like http://noida.saamstesting.com
Hello Friends,
I've a folder named "noida" in my project and some pages in that folder And now i've to open those pages like http://noida.saamstesting.com/Page1.aspx .
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Puran KaushalPosted Jun 2, 2009, 5:57 AM
It's very simple few lines of code.
I am giving you that just check
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text.RegularExpressions;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo di = new DirectoryInfo(Server.MapPath("Puran"));
FileInfo[] rgFiles = di.GetFiles("*.aspx");
foreach (FileInfo fi in rgFiles)
{
Response.Write("
+ fi.Name + "> http://noida.saamstesting.com/" + formatString(fi.Name) + ".aspx");
}
}
private string formatString(string url)
{
url = Regex.Replace(url, "-", " ");
url = Regex.Replace(url, ".aspx", "");
return url;
}
}
You even do not need formatString but i have written for further use
Regards
Puran