Solved

ASP.NET/VB.NET displaying URL path

Posted on 2011-09-28
2
269 Views
Last Modified: 2012-05-12
Some easy points up for grabs

Im a looking to extract PART of the url name from the current page, Im using the request.url but only want to return the servername  and webstite.

i.e I want to return  http:\\myserver\mywebsite

currently it is returning

http:\\myserver\mywebsite\mywebpage

Does anyone the syntax or point me in the right direction please.
0
Comment
Question by:MrDavidThorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 36717580
try using below Regex method and see whether you can get what you want by passing in the URL

public static string ExtractDomainName(string Url)
{
return System.Text.RegularExpressions.Regex.Replace(
Url,
@"^([a-zA-Z]+:\/\/)?([^\/]+)\/.*?$",
"$2"
);
}
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 36717709
Dim address As String = "http:\\myserver\mywebsite\mywebpage"
Dim server As String

server = address.Substring(0, address.LastIndexOf("\"c))

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

688 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