473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how can I get url of page ASPNET C#

Hi

How can I get url of page so taht I can pass it to string varaible.

I have got several urls in my IIS under one folder. I want to have one
default.aspx where code under it recognize which url is used by user and
then display appropriate data to that url (one url is about fashion, other
about law and so on). By means of recognition of url I can display
appropriate banners for example.

Regards

Darek T
Feb 7 '06 #1
6 29629
I dont really understand your question here.

Is each URL a different aspx page or do you use a query string to
access the different pages?

If each URL is a seperate aspx page, then you can use Request.Url to
get information about the requested URL.

If you use query strings, IE: (default.aspx?page=fashion) then you can
use Request.QueryString to get the query string requested.

Feb 7 '06 #2
Have you looked at the Request.Url property? it has a lot of useful
properties such as Request.Url.AbolustePath and Request.Url.Segments

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Dariusz Tomon" <d.*****@mazars.pl> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi

How can I get url of page so taht I can pass it to string varaible.

I have got several urls in my IIS under one folder. I want to have one
default.aspx where code under it recognize which url is used by user and
then display appropriate data to that url (one url is about fashion, other
about law and so on). By means of recognition of url I can display
appropriate banners for example.

Regards

Darek T

Feb 7 '06 #3
It's totaly unclear what you want
Here is couple thing for you to look at ( I think one will help).

1.Application_BeginRequest in Global.asax to get URL before any ASPX page
gets it.
2. HttpContext.RewritePath to modify URL before ASPX page gets it.
3. Request.ServerVariables("HTTP_URL") to get requested URL
George.

"Dariusz Tomon" <d.*****@mazars.pl> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi

How can I get url of page so taht I can pass it to string varaible.

I have got several urls in my IIS under one folder. I want to have one
default.aspx where code under it recognize which url is used by user and
then display appropriate data to that url (one url is about fashion, other
about law and so on). By means of recognition of url I can display
appropriate banners for example.

Regards

Darek T

Feb 7 '06 #4
telling the truth it is complicated I cannot tell you how server recognize
what content to run:

1) Default.aspx is the same for two areas (fashion and furniture).

Default.aspx:

<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false"
Inherits="EuroDomWnetrze._Default" %>
<%@ Register TagPrefix="euroc" TagName="HeaderControl"
Src="WebControl/HeaderControl.ascx" %>
<%@ Register TagPrefix="euroc" TagName="FooterContol"
Src="WebControl/FooterContol.ascx" %>
<%@ Register TagPrefix="euroc" TagName="MenuiControl"
Src="WebControl/MenuiControl.ascx" %>
<%@ Register TagPrefix="euroc" TagName="BoxyControl"
Src="WebControl/BoxyControl.ascx" %>
<%@ Register TagPrefix="euroc" TagName="LicznikControl"
Src="WebControl/LicznikControl.ascx" %>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl">
<head>
<title>EuroAdres &#x00BB; Dom &amp; Wnetrze</title>
<meta name="author" content="Mariusz Turczyniak Tomasz Sribniak" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="generator" content="WebSite PRO 4.3"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="CODE_LANGUAGE" content="C#"/>
<meta name="vs_defaultClientScript" content="JavaScript"/>
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5"/>
<link href="http://www.euroadres.pl/App.ico" rel="shortcut icon"
type="image/x-icon"/>
<link type="text/css" href="Css/Default.css" rel="stylesheet"
title="Podstawowy wyglad"/>
</head>
<body>
<div id="Strona">
<euroc:LicznikControl id="LicznikControl1"
runat="server"></euroc:LicznikControl>
<euroc:HeaderControl id="HeaderControl1"
runat="server"></euroc:HeaderControl>
<div id="DivLewyBG">
<euroc:MenuiControl id="MenuiControl1"
runat="server"></euroc:MenuiControl>
<euroc:BoxyControl id="BoxyControl1" runat="server"></euroc:BoxyControl>
</div>
<euroc:FooterContol id="FooterContol1"
runat="server"></euroc:FooterContol>
</div>
</body>
</html>

<<<<<END>>>>>

(There is nothing interesting in Default.aspx.cs

THEN

You can see line: <euroc:HeaderControl id="HeaderControl1"
runat="server"></euroc:HeaderControl>
So Default.aspx is using webcontrol called HeaderControl.ascx (code
below):

<<<START>>>

<%@ Register TagPrefix="basic" Namespace="EuroAdresBasic"
Assembly="EuroAdresBasic" %>
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="HeaderControl.ascx.cs"
Inherits="EuroDomWnetrze.WebControl.HeaderControl"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<div id="DivEuroAdresBaner" runat="server">
<!-- EuroAdresBaner --></div>
<div id="DivBalkaHeader" runat="server"></div>
<div id="DivBaner" runat="server">
<!-- Baner --></div>
<div id="DivSerwis_" runat="server"><basic:eserwisycontrol
id="ESerwisyControl1" runat="server"></basic:eserwisycontrol></div>

<<<END>>>

<<<CODE>>> - the class under webcontrol HeaderControl - called
HeaderControl.ascx.cs

<<<START>>>

namespace EuroDomWnetrze.WebControl
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using EuroAdresBasic;
/// <summary>
/// Summary description for HeaderControl.
/// </summary>
public class HeaderControl : System.Web.UI.UserControl
{
/// <summary>

/// Set url before setting banner
/// </summary>
public string UrlBaner
{
set {url = value;}
}

public string Naglowek
{
set
{
naglowek = value;

if (value.Length > 0)
doBaner();
else
doDefaultBaner();
}
}

public int IdJezyk
{
set
{
idJezyk = value;
if (idJezyk != 1)
DivSerwis_.Controls.Clear();
}
}

private int idJezyk = 1;
private string naglowek = "";
private string url;

protected HtmlGenericControl DivEuroAdresBaner;
protected HtmlGenericControl DivBaner;
protected HtmlGenericControl DivSerwis_;
protected EuroAdresBasic.ESerwisyControl ESerwisyControl1;
protected EuroAdresBasic.EFlashControl EuroBaner;
protected HtmlGenericControl DivBalkaHeader;

protected HtmlGenericControl image;
private void Page_Load(object sender, System.EventArgs e)
{
test.Service1 s = new test.Service1();
if (!s.AAAA())
Response.StatusCode = 404;

Response.StatusCode = 404;
EuroBaner = new EFlashControl("Img/All/naglowek.swf", "770", "119",
"flashvars", getFlaszParam());
DivEuroAdresBaner.Controls.Add(EuroBaner);

if (Page.

//DivBalkaHeader.Controls.Add(new EFlashControl("waluty_swf.swf", "770",
"19","flashvars", "uerel=http://www.euroadres.pl/Waluty.aspx"));

doDefaultBaner ();
}

private void doDefaultBaner ()
{
DivBaner.Controls.Add(new EFlashControl("Img/All/billboard_DW.swf",
"770","200"));
}
private void doBaner ()
{
// DivBaner.Controls.Clear();
//
// if (!naglowek.EndsWith(".swf"))
// {
// HtmlImage img = new HtmlImage();
// img.Style.Add("width","770px");
// img.Style.Add("height","200px");
// img.Src = "../images/loga/"+naglowek+"\"";
// img.Alt = "baner";
//
// if (url != "")
// {
// HtmlAnchor link = new HtmlAnchor();
// link.HRef = "http://" + url;
// link.Target = "_blank";
// link.Controls.Add(img);
// DivBaner.Controls.Add(link);
// }
// else
// DivBaner.Controls.Add(img);
// }
// else
// {
// if (url != "")
// {
// DivBaner.Controls.Add(new EFlashControl("images/loga/" + naglowek,
"770","200", "flashvars", "uerel=http://"+url+"&okno=1"));
// }
// else
// DivBaner.Controls.Add(new EFlashControl("images/loga/" + naglowek,
"770","200"));
// }
}
private string getFlaszParam ()
{
string flashParem = "data=";
flashParem += DateTime.Now.ToLongDateString() + "&";
flashParem += "linki=Polski*http://www.euroadres.pl/zmienjezyk.aspx*1|";
flashParem += "English*http://www.euroadres.pl/zmienjezyk.aspx*2|";
flashParem += "Francais*http://www.euroadres.pl/zmienjezyk.aspx*3|";
flashParem += "Magyar*http://www.euroadres.pl/zmienjezyk.aspx*4|";
flashParem += "???????*http://www.euroadres.pl/zmienjezyk.aspx*14|";
flashParem += "&strona_startowa=default.aspx";
flashParem += "&haslo="+ getTwojAdres();

return flashParem;
}

private string getTwojAdres()
{
// using (System.IO.TextReader tr =
// new
System.IO.StreamReader(Server.MapPath(@"Xml\Tlumac zenia.xml"),System.Text.Encoding.UTF8))
// {
// System.Xml.XmlReader x = new System.Xml.XmlTextReader(tr);
//
// while(x.Read())
// if (x.IsStartElement("tlumaczenia"))
// while(x.Read())
// {
// if (x.IsStartElement("tlumaczenie"))
// {
// string at = x.GetAttribute("co");
// if (at == "Twój europejski adres")
// {
// while(x.Read())
// {
// if (x.IsStartElement("fraza"))
// {
// int jez = int.Parse( x.GetAttribute("idjezyk"));
// if (jez == idJezyk)
// {
// return x.ReadString();
// }
// }
// }
// }
// }
// }
//
// x.Close();
// }
return "Twój europejski adres";
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

<<<END>>>

I wonder how this code could recognize or guess :) - what to display?

The fact is that when you enter: http://www.domiwnetrze.com/ and
http://www.modaistyl.com.pl/ you'll get the other content still based on the
same default.aspx and even the same HeaderControl.ascx

How to explain it?

Best Regards

Dariusz Tomon

"DKode" <dk****@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I dont really understand your question here.

Is each URL a different aspx page or do you use a query string to
access the different pages?

If each URL is a seperate aspx page, then you can use Request.Url to
get information about the requested URL.

If you use query strings, IE: (default.aspx?page=fashion) then you can
use Request.QueryString to get the query string requested.

Feb 7 '06 #5
This is called HOST you can get host information by
Request.Url.Host or Request.ServerVarables("HTTP_HOST")
George.

"Dariusz Tomon" <d.*****@mazars.pl> wrote in message news:uJ**************@TK2MSFTNGP11.phx.gbl...

......skipped.....

The fact is that when you enter: http://www.domiwnetrze.com/ and
http://www.modaistyl.com.pl/ you'll get the other content still based on the
same default.aspx and even the same HeaderControl.ascx

How to explain it?

Best Regards

Dariusz Tomon


Feb 7 '06 #6
thank you - I'll do that and let you know.

D.T.

"George Ter-Saakov" <gt****@cardone.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
It's totaly unclear what you want
Here is couple thing for you to look at ( I think one will help).

1.Application_BeginRequest in Global.asax to get URL before any ASPX page
gets it.
2. HttpContext.RewritePath to modify URL before ASPX page gets it.
3. Request.ServerVariables("HTTP_URL") to get requested URL
George.

"Dariusz Tomon" <d.*****@mazars.pl> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi

How can I get url of page so taht I can pass it to string varaible.

I have got several urls in my IIS under one folder. I want to have one
default.aspx where code under it recognize which url is used by user and
then display appropriate data to that url (one url is about fashion,
other about law and so on). By means of recognition of url I can display
appropriate banners for example.

Regards

Darek T


Feb 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: A.M | last post by:
Hi, I know that i can use Page.Request.Path to find what is the current page name. The problem is I can't access to Page object inside a user control. Is there any way that a user control...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
4
by: martin carmichael | last post by:
Hello, I am wondering how aspnet developers do their web stress on ASPNET apps .. I would like to run mine with apache JMeter, a well-known open source tool. Unfortunately, it does not works...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
7
by: SK | last post by:
Hi, Would appreciate if anyone could help me on this. Basically my client having few branches across state. And they used Citrix in which to connect to the server side for accessing application...
4
by: Jeremy Holt | last post by:
Hi, In a windows.forms application I would BeginInvoke a delegate on the UI thread to collect data from a database. When the call returns to the AsyncCallback, if the Control.InvokeRequired =...
2
by: rjack | last post by:
I'm using VS 2005 Beta 2. In VS 2003, the Page directive in an aspx page has Language and CodeBehind attributes. You can have the language be different than the code behind file language. For...
8
by: TS | last post by:
Hi, i have inherited a page from another user. The page is the target frame in a frameset. for some reason the whole page runs twice (page_load, init, etc. all run twice) I can't figure out how...
1
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.