How can I set up my ASP.NET project to search for my files?

edit I do not want to redirect pages, specific files, etc. I would like to change the way in which images, videos and other media are stored from the root source directory to the directory of my choice , In this case c: / dev / prjfiles / prjname / public (c: / dev / prjfiles / prjname / is my working directory) and i, unless my html does img src = "/pic.png", it will find the image in c: /dev/prjfiles/prjname/publi/pic.png. I need a working solution, I tried to see how to install virtual directories, etc. I can’t figure it out. Therefore, generosity. I generate html,, I do not write asp:image runat="server"etc. I am extracting data from a DB and outputting html. The part that is still WIP is the code that processes the POST request. Html already exists, but I can’t have hundreds of files on site.com/here polluting my source directory (c: / dev / trunk / thisprj / thisprj / where my .aspx files are, and I don’t want 500.png / gif / jpg here)

I do not know how asp.net environments are usually installed. I assume that I have a root path that is not accessible from the Internet, bin / where, where I can put my asp.net dll and the publication in which I enter any files that I want.

I would like my project files to be separated from everything else. My JS, css and image files are in prjfiles / prjname / public with my sqlite db in prjfiles / prjname / and additional binaries in prjfiles / prjname / bin.

The problem occurs when I run my application and try to download an image. For example, /cssimg/error.png. My project does not find the resource in my / shared folder, and I have no idea how to find it. How can I set up my project so that it does?

NOTE. I set the path to the working directory so that it is in prjfiles / prjname /. I am writing in code. /bin/extrabin.exe and db.sqlite3, which access files correctly.

+3
source share
7 answers

You might want to watch started videos for ASP.NET

http://www.asp.net/get-started/

EDIT: Additional information added.

@Murph, . IIS HTTP , *.aspx.cs *.cs App_Code, DLL, - App_Data web.config.

, *.html, *.css, *.js,.gif,.jpg,.png, .

, "" .

+5

, asp.net. , , , bin/where, dll asp.net , , .

!

  • , . IIS ASP.NEt Development Server .
  • (, ) web.config
  • ( ) " ".
  • () App_Data / (, XML)..
  • () App_theme . ASP.NET.
  • () App_Code, , .
  • ..

.. bin.

, ASP.NET IDE . Visual Web Developer 2008 Express IDE http://asp.net .

+4

, , , , <BASE> HTML.

HTML <BASE>

" URL- "

W3Schools , .

, <BASE> .

+2

, , , , .

, IIS DLL , .

, cssimg .

+1

, . ASP.NET , , , .

ASP.NET . WebSite Visual Studio, default.aspx . IIS? , default.aspx . .



, , ( ):

-, "prjfiles". "public". , cssimg.

, , : "~/prjfiles/public/cssimg/error.png" ( ) "./cssimg/error.png" ( ).



, . , :

-, "cssimg".

, "" - , . , : "./cssimg/error.png" () "~/cssimg/error.png" ( root)



, , css. "head" "style" ( = "/css" ), - : @import '<% = ResolveUrl ( "~/prjfiles/public/cssimg/styles.css" )% > ';



!

+1

, , . , UrlRewrite.

URL- ASP.NET , : URL- ASP.NET 2.0.

+1

( ) , <img src="/img.png" />, .

, , , , images . <img src="/images/img.png" />.

.

0

Source: https://habr.com/ru/post/1727337/


All Articles