1

I have some text files (and others) that I want to be hidden from the public when deploying an ASP.net project. How do I do that? (And what's the technical term for that? "hidden"? Searching, I couldn't find an answer to this so I'm probably using the wrong term.)

Also, if you know of a way to specify not to upload certain files when publishing - I'd like to hear it. (I know I can do that by excluding them from the project, but I rather they stay included because I use them while debugging on localhost.)

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • You can put them in the App_Data folder in your project that is available on the webserver but not accessible from the website. – Caspar Kleijne Nov 18 '12 at 20:53
  • @CasparKleijne You can transform your comment to an answer. And just to clarify: Anything in that folder will be not accessible to anyone on the web? – ispiro Nov 18 '12 at 21:01

2 Answers2

2

I suppose if you want the files to be included, but not reachable via web request, you could look at the IIS redirect module. As for not uploading a file at all, simply select the item in the solution explorer, right-click and select properties (or press F4), and change the build action to none. Files should only be included in a deployment if you choose content.

tostringtheory
  • 877
  • 8
  • 19
  • You also have to set the "Copy to Output Directory" option to "Do not copy" – NotMe Nov 18 '12 at 20:54
  • Isn't that the default value anyways for non-compiled files? If the copy to output directory is on however, it won't go into its same logical path as the solution explorer shows, it will instead be dropped into the bin directory. – tostringtheory Nov 18 '12 at 20:58
  • All I know is that we have several web app projects that get deployed on top of each other and we had to set the "Do not copy" on all but one of them to prevent the child projects from overwriting the parent projects config file. – NotMe Nov 18 '12 at 20:59
  • Wow, that is definetly not normal! I'll have to keep that in mind if I ever have an issue like that pop up. ** *knocking on wood* ** – tostringtheory Nov 18 '12 at 21:01
  • Thanks. About the hiding - I'm searching that now. But it seems that's something I do externally. Not in the publishing itself. Am I correct? About the not-uploading - that would prevent them from being used on localhost as well. Or did I misunderstand something? – ispiro Nov 18 '12 at 21:06
  • As for hiding, yes, that is something of an external thing. However with the IIS redirect module, you can configure it in your web applications web.config file. The not-uploading would not effect your projects functionality while debugging, since you debug out of the directory the solution lives in anyways - the files will still be there. It will only effect your published product. – tostringtheory Nov 18 '12 at 21:12
2

You can put them in the App_Data folder in your project that is available on the webserver via the file system or your application but not accessible from the internets.

Caspar Kleijne
  • 21,552
  • 13
  • 72
  • 102