get view cshtml code as string in c# using base ur code example Example: mvc get base url Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~")