Appending current url

Posted on 2013-09-22
Medium Priority
Last Modified: 2013-09-30
Hi Experts,

I am working on ASP..net 2.0 using c#. I need help in logic

Problem: Need to capture current complete url without query string.
If url ends with index.aspx. Replace index.aspx with Index.aspx

for example:

should result: http://kdlkjdld:8738/Index.aspx

should result: http://www.abc.com/Index.aspx

should result: http://www.abc.com/Index.aspx

should result: http://www.abc.com/Index.aspx

should result: http://www.abc.com/path1/Index.aspx

should result: http://www.abc.com/path2/index.aspx

Please advise

Question by:tia_kamakshi
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39513741
Why would you need to capitalize the I? Case shouldn't matter in IIS.

Author Comment

ID: 39513852
We capture this in Omniture. Omniture captures this as 2 different urls.

So need it this way only.

Please advise
LVL 52

Accepted Solution

Carl Tawn earned 2000 total points
ID: 39514388
The following will build you a string with the adjusted URL:

string url = Request.Url.Scheme + "://" + Request.Url.Host + Request.Url.AbsolutePath.Replace("index.aspx", "Index.aspx");

Open in new window


Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question