virtual-path

How do you convert a url to a virtual path in asp.net without manual string parsing?

烈酒焚心 提交于 2020-01-22 20:09:20
问题 I've seen similar questions and answers regarding conversions from virtual to absolute and url, but how can I convert a url to a virtual path without manual string parsing? Example: I want "http://myserver/home.aspx" converted to: "~/home.aspx" I realize the above example would be an easy string parsing routine, but I'm looking for a proper solution that will scale to the changing of the url format. 回答1: You can get most of it from the Uri class: new Uri("http://myserver.com/home.aspx")

How to set the Site-Root Relative Path (for localhost) on IIS on my web application

一世执手 提交于 2020-01-15 07:12:06
问题 I create a new Web Site, in localhost, called Example1, on Visual Studio (2008); than if I wrote : <img src="/private_images/club.png" /> the "path" that IIS should consider of should be localhost/Example1/private_images/club.png , but in fact it consider localhost/private_images/club.png . So I should configure out IIS and my application in the right way (for each application). I know I can do it, because, in fact, online (from my hosting) it works as well. How can I do it? Tried this

ASP.NET - How to get assembly from virtual path in custom IResourceProvider implementation

心不动则不痛 提交于 2020-01-05 08:11:32
问题 I'm developing custom local resource provider implementation, which should supply resource values from resources located in App_LocalResources folders, but the resources should be compiled as embedded. So no resx files will stay in web app folder, which default LocalResXResourceProvider expects. The problem is I need to get to assembly with the embedded resources from virtual path and I'm not able to figure out what ASP.NET class use to translate virtual path to corresponding assembly. I was

ASP.NET - How to get assembly from virtual path in custom IResourceProvider implementation

杀马特。学长 韩版系。学妹 提交于 2020-01-05 08:11:04
问题 I'm developing custom local resource provider implementation, which should supply resource values from resources located in App_LocalResources folders, but the resources should be compiled as embedded. So no resx files will stay in web app folder, which default LocalResXResourceProvider expects. The problem is I need to get to assembly with the embedded resources from virtual path and I'm not able to figure out what ASP.NET class use to translate virtual path to corresponding assembly. I was

asp.net - Is my path virtual?

让人想犯罪 __ 提交于 2019-12-24 11:35:50
问题 Is there a built-in asp.net method for checking the "virtualness" of a path? The only way I've been able to do it so far is with the following try block: public void Foo(String path){ try { path = Server.MapPath(path); } catch(HttpException){} // do stuff with path } 回答1: Would the Path.IsPathRooted method work? You're resulting code would be: public void Foo(String path) { if(!Path.IsPathRooted(path)) { path = Server.MapPath(path); } // do stuff with path } 回答2: Here is everything you need

How to get server path of physical path ?

…衆ロ難τιáo~ 提交于 2019-12-22 04:00:53
问题 I want to convert this physical path "C:\bla\bla\Content\Upload\image.jpg" to server path like "/Content/Upload/image.jpg" . How can i do that ? 回答1: you can use something like that : public static class Extensions { public static string RelativePath(this HttpServerUtility utility, string path, HttpRequest context) { return path.Replace(context.ServerVariables["APPL_PHYSICAL_PATH"], "/").Replace(@"\", "/"); } } and you call Server.RelativePath(path, Request); 回答2: You can do the following to

How can I activate “Use Visual Studio Development Server” options on Visual Studio 2013?

三世轮回 提交于 2019-12-12 02:58:19
问题 I want to clear Solution Virtual Path on Visual Studio 2013 but I can't find " Use Visual Studio Development Server " options when right click on Solution like in Visual Studio 2012 . Can you help me? Thank you. 回答1: Long story short It's been discontinued Your only option now is to use IIS Express, or normal IIS. Here are some sources backing it up. 来源: https://stackoverflow.com/questions/25869010/how-can-i-activate-use-visual-studio-development-server-options-on-visual-stud

ASP.net - The virtual path '/Master.master' maps to another application, which is not allowed

江枫思渺然 提交于 2019-12-11 00:48:13
问题 I have an asp.net master page located in the root directory of my site. I have a page in the directory "/myfolder" from the master page: <%@ Page Title="" Language="C#" MasterPageFile="../Master.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myproject.TimelapseDefault" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <p> The files look like: /Master.master /myfolder/default.aspx Why do I get this error, when I upload it to my (non

How to get server path of physical path ?

本秂侑毒 提交于 2019-12-05 02:40:12
I want to convert this physical path "C:\bla\bla\Content\Upload\image.jpg" to server path like "/Content/Upload/image.jpg" . How can i do that ? you can use something like that : public static class Extensions { public static string RelativePath(this HttpServerUtility utility, string path, HttpRequest context) { return path.Replace(context.ServerVariables["APPL_PHYSICAL_PATH"], "/").Replace(@"\", "/"); } } and you call Server.RelativePath(path, Request); You can do the following to get the relative path. String filePath = @"C:\bla\bla\Content\Upload\image.jpg"; String serverPath = Request

How do you convert a url to a virtual path in asp.net without manual string parsing?

旧街凉风 提交于 2019-12-04 07:36:08
I've seen similar questions and answers regarding conversions from virtual to absolute and url, but how can I convert a url to a virtual path without manual string parsing? Example: I want " http://myserver/home.aspx " converted to: "~/home.aspx" I realize the above example would be an easy string parsing routine, but I'm looking for a proper solution that will scale to the changing of the url format. You can get most of it from the Uri class: new Uri("http://myserver.com/home.aspx").AbsolutePath Then you just have to prepend the ~ Though, that will might break if you host in a subdirectory -