Solved

ASP.NET/VB.NET displaying URL path

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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