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
Solved

ASP.NET/VB.NET displaying URL path

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linq asp.net mvc 13 17
Generate Numbers in JQuery file 11 66
Passing data between Forms 3 20
Validating textboxes in red square borders. 2 9
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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