Solved

ASP.NET/VB.NET displaying URL path

Posted on 2011-09-28
2
236 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now