Web Forms :: How To Track The Path Of Current Page
Feb 14, 2011i want to know that from which pages my current page has been called in ASP.net
View 1 Repliesi want to know that from which pages my current page has been called in ASP.net
View 1 Repliesi want to know that from which pages my current page has been called in ASP.net As for example I want the track of page named "hero.aspx" and it has been called from "Zero.aspx" and "Zero.aspx" has been called from "one.aspx" So i want output as whole page called hierarchy.How can i get this in asp.net
View 3 RepliesTo get the url of the current page, I usually do something like this:string path = Request.Path;If I do this after a Server.Transfer then I get the path of the page where the transfer was done. How can I get it for the current page?For example:
On Page1.aspx I do Server.Transfer ("Page2.aspx")
On Page2.aspx Request.Path returns /Page1.aspx and not /Page2.aspx
I am doing Ajax call using jQuery and my URL is like
http://localhost;3327/DummyAps/Demo.aspx
In Demo.aspx page i have a WebMethod, which i wanted to call. While doing jQuery ajax call i am giving the URL as "/DemoWebMethod", where "DemoWebMethod" is the Webmethod present in Demo.aspx page.
But while calling the WebMethod it is calling the URL
http://localhost;3327/DummyAps/DemoWebMethod but i want to call
http://localhost;3327/DummyAps/Demo.aspx/DemoWebMethod.
I know that changing the URL from "/DemoWebMethod" to "Demo.aspx/DemoWebMethod" will solve the problem but can i do it without writing that (because i have some problem with that).
How would I keep track of number of current sessions on my website?
View 5 RepliesScenario is I have a application relative url like "~/path/to/page.aspx?query=string". I need to programatically create a web request to that page and currently using WebRequest.Create. The problem is WebRequest.Create requires a fully qualified url including the protocol/domain/port etc.I have access to the current Request.Url object but there doesn't seem to be an easy way to get just the base url keeping the protocol (HTTP vs HTTPS) as well as any port numbers as well as the path to the applicationI mean all the info there, so if need be I could just take all the parts and combine them but it seems like it might be error prone and it would be great to have something built-in that's well tested to do the job. Page.ResolveUrl gets me almost there, but it's missing the protocol and the domain/port.
View 1 RepliesI have a PHP website and I am looking to convert it into ASP.NET. So I am learning ASP.NET and I needed a way to upload multiple files to the server. So I ran across this tutorial: [URL] I did everything correct, but I get this error:
Compiler Error Message: CS0103: The name 'Path' does not exist in the current context
Source Error:
[Code]....
Source File: c:UsersUser1DesktopUweaveLigues Hockey SimulesViewsAdminFormIndex.aspx
Line: 18
I am looking for a way to figure out the current URL that the page is currently on (NOT what the asp.net page currently is, but where the CODE is at). ie. My web app is located at: [URL] my code is: String page = [URL]
String response = GetResponse(page); //basically the above code goes to the website [URL] and parses the HTML within it and brings it back and populates the variable string "response". But, sometimes the [URL] throws me a curve ball and redirects me to: [URL] I want to be able to use a try/catch to be able to "catch" the error of a different page: ie validateUser.aspx. So, I need to do to this: try
{
String page = [URL];
String response = GetResponse(page);
}
catch
{
//code to check the behind URL to see if [URL] is the URL OR IF [URL] is the current URL
}
understand I know how to find the URL of the current page the web app is on. I need to find the current page that threw the exception during the execution of the code behind.
I used Directory.GetCurrentDirectory(); and got the following path:
C:Program FilesMicrosoft Visual Studio 9.0Common7IDE
But where I am realy at is c:c#mvcmyProject
How do I get the current directory in a controller not in c:Program Files...?
I am redirecting from A.aspx to C.aspx and B.aspx to C.aspx.In C.aspx i have a button "Back Page". I am implementing as below.If there is a better way pls let me know.
In A.aspx and B.aspx before redirecting to C.aspx,saving the LastPageURL in session
Dim lastPage as string = Request.UrlReferrer.AbsolutePath
Dim sArray() as string = lastPage.split("/")
lastPage = sArray(Array.Length-1)
Session("LastURL") = lastpage
On click of Button "Back Page" in C.aspx
Response.Redirect(Session("LastURL"),True)
Request.Path will get the current Path name with file name such as:
C:/......./Personal/Items.aspx
How can I get the only Path name such as:
C:/......./Personal
Suppose I have a resource located in ~/Resources/R1.png This resource's relative URL will vary depending on the current address.
For instance: If I'm at www.foo.com/A/B/C/D.aspx and the www.foo.com/A is the root path including Virtual Directory, then the path relative to the current address of ~/Resources/R1.png is ../../../Resources/R1.png
How can I get this relative path?
EDIT:
I want a web path that I can use in a web page, not a server path.
What I want is I that I want to keep track of number of visits per page and average time spent on each page and the site. I don't want to use any third (3rd) party tool. How to achieve this with minimum code.
View 5 RepliesI am building in error-logging into my site, and want to be able to get hold of the current page name that the error occurred in, as well as the specific subroutine or function, to then pass to a VB.NET function. Is there anyway to get hold of this information without hard-coding the names manually? For example,
Dim strCurrentPageName = ???
Dim strCurrentRoutine = ???
I have a page on my site, for purposes of this example lets say [URL]. On Default.aspx I have a user control called MyControl.ascx which lives in /Controls/MyControl.ascx. So the tree looks something like this
[code]...
Whenever I place a HyperLink control on MyControl.ascx and specify a NavigateUrl, this path is relative to the control, not the URL of the page. So for instance if in NavigateUrl I specified "AboutMe.aspx", the URL would be rendered as [URL] instead of [URL]. Is there any way I can make this relative to the page URL? I've tried the solution here: [URL] but it didn't work for me.
Edit
To clarify, I'd like this to be generic enough so that if I didn't know what the path was the solution would work. So I don't really want to harcode "~/Pages/Default.aspx" in the NavigateUrl
I have three pages calculator1.aspx, calculator2.aspx and Menu.aspx. On each calculator page i have a button that redirect me to Menu page and on Menu page i have to go back to Calculator1 or calculator2 page from where the request initiated. So how can i differentiate from which page my request come when im on Menu page.
View 3 RepliesI've got a dynamic page where I'd like to track the time the user spends on it.
View 5 RepliesI am currently working on a project where I want to implement a bit of logic for each .aspx viewed.My idea was to use an httphandler that will target *.aspx, and in the handler, I would do my bit of logic, such as printing out: This is the xth page you have visited in this session.I am curious if there are any problems with my idea or is there a more proper solution I am not aware of.Though I have tried implementing my solution, I run into an infinite loop. After I complete my logic with the handler, I redirect to the same page, but that of course calls the same handler. Is there a way to bypass the handler on the redirect or a specific way to execute the same page without accessing the handler.
I am trying to create a java script function to keep track of the changes made in a web form while submitting the page. For normal .net textbox or textarea I can compare the value with default value.
var ele = document.forms[0].elements;
for ( i=0; i < ele.length; i++ )
{
if ( ele[i].value != ele[i].defaultValue ) return true;
}
But the problem is, I have a dnn texteditor in my web page. And ele[i].value does not change if user change the text in the texteditor. It always returns false as it could not track the changes.
Is there any attributes of the dnn texteditor control that holds the changes data?
We are using Google Analytics for our site, but since it uses client script in HTML output we are unable to track hits to any of our ASP.NET ASHX handler pages.
View 2 RepliesMy intention is to give the user a flexible user control on a master page that does the following:
When navigating, a child page will pass the URL (with querystring) and PageTitle to the user control. The user control will take those two parameters and insert them as a "breadcrumb" object at first index of a List<breadcrumb> collection
This part works fine through the use of a Repeater with a LinkButton contained in an ItemTemplate. The user sees each of the pages he has been visiting in descending order, the provided benefit is a quick way to re-open records they have recently modified or created.
The part I'm having trouble handling is what happens when the user clicks the LinkButton, which is that the child page adds a new reference to the URL at the beginning of the List<> collection and I cannot seem to control the behavior of removing the LinkButton before it gets re-created. What I've tried doing is:
List<>.RemoveAt(RepeaterCommandEventArgs.Item.ItemIndex);
Repeater1.Controls.Clear();
Repeater1.DataSource = List<>;
Repeater1.DataBind();
While that should work, my CreateBreadCrumb(string url, string title) function gets called by the child page before the UserControl detects the Repeater1_ItemCommand event, so in effect it appears that the wrong ItemIndex is being used for removal.
I am experiencing an issue with the TreeView control when loading new pages. It is databound to web.sitemap, but when loading a new page, it does not select the node of the current page, just resets it to the root. THe new page loads fine, just not preserving the current navigation in the tree view.
View 2 Repliesi want to see my textbox value when i click on previous button in another page
then display my 1st page enter textbox value.
I'm new to ASP.net (and coding in general) and I was very impressed about how easy is to learn enough to create something useful :)
Unfortunately, now I'm stuck on a problem involving gridview sorting and paging: I created a master gridview bound to an sqldatasource, I enabled sorting and paging and then I linked it to a detailsview to enable editing and inserting.
In addition, I set up two other gridviews whose datasources depend on the master gridview.
When a user selects a row and modifies it in the detailsview, the sort takes place and the row is often moved to another page. This can be a little confusing, especially because there are other controls relying on the selected row of the master gridview.
There's a way to find and select the page of the selected row after gridview's databind and sort take place? I tried creating a dataview to search the index of the selected datakey in the databound event of my gridview, but it doesn't work, because it seems that the rows aren't sorted yet. Maybe I should choose another event?
I want to access controls (textbox and HTML hidden fields) from current page to do some transactions in my database.
View 3 Replies