Solved

ASP.NET/VB.NET displaying URL path

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hovering effect 9 30
Round a string to two digits 12 25
Format column on datatable 7 18
ASP.NET Web API or ASP.NET Core MVC? 3 32
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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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