how to create search engine for a site.
is there some code is avaliable for that in asp.net .
help its important
Loading
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.
Gomathi PalaniswamyPosted Oct 18, 2010, 12:52 AM
Write the below coding in button click event,it will retrieve the web page and write on default page
string MyString = "";
if (TxtBN.Text != "")
{
MyString = TxtBN.Text;
}
else if (TxtAuthor.Text != "")
{
MyString = TxtAuthor.Text;
}
if (MyString != "")
{
string Address = "http://www.stmarksbookshop.com/search/apachesolr_search/" + MyString;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Address);
WebResponse response = null;
StreamReader reader = null;
response = request.GetResponse();
reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string result = reader.ReadToEnd();
reader.Close();
if (result.Contains("Search results"))
{
int k = result.IndexOf("
int g = result.IndexOf("
string Final = result.Substring(k, g - (k));
string Path = Server.MapPath("~/");
string Code = "<%@ Page Language=\"C#\" MasterPageFile=\"~/MasterPage.master\" AutoEventWireup=\"true\" CodeFile=\"Default.aspx.cs\" Inherits=\"_Default\" Title=\"Search Results\" %>" + "\n" + "
Code = Code + Final + "\n" + "
StreamWriter sr1 = new StreamWriter(Path + "Default.aspx");
sr1.WriteLine(Code);
sr1.Close();
Response.Redirect("Default.aspx");
}
else
{
LblMsg.Text = "No Data Found";
}
shilpi guptaPosted Oct 17, 2010, 7:13 AM
do i put that code on search button click.
my problem is that
I have created a auction website and I need to have a search engine on master page. When I type 'belt', all the words containing belt should appear. I used a textbox, a button, I type the text I wanna search into the textbox, and click the button. Information will appear on the page
like
i have various item on page. that detail infomation is store in db.(like belt price ,pic, size.colour etc.)
when user type belt.
is move to belt page ---> like that ->home-> men-> accc-> belt
direct. then it show its detail from db
Gomathi PalaniswamyPosted Oct 17, 2010, 6:53 AM
first get the page source like
WebRequest Request = WebRequest.Create("URL");
WebResponse Response = Request.GetResponse();
Stream RStream = Response.GetResponseStream();
Encoding en = System.Text.Encoding.GetEncoding("utf-8");
StreamReader read = new StreamReader( RStream, en );
string str=read.ReadToEnd();
and made searches in the str(source page) and display on default page