Determining the Temporary ASP.Net files folder location for a specific site - asp.net

I have a server with dozens of web sites running on it, and I'm experiencing bad caching behavior on a few of them. I would like to delete the .COMPILED files that ASP.Net caches for them, but I am unable to determine the specific cache folder for a specific site. Underneath the Temporary ASP.Net files folder location are series of folders with arbitrary names (looks like parts of a GUID).
Is there a way to figure out which folder ASP.Net is using to cache files for a specific site?

You can use HttpRuntime.CodegenDir property.
It will return path like:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\website1\c2a2b44f\ce865b50
For more reference take a look at msdn site.

Related

Is there a way to tell a View in ASP.NET where to look for a Web.Config?

I've recently began a new project and I've decided to try to arrange the folders in a basic ASP.NET MVC project by feature (i.e. one folder would contain all Account files Models, View and Controller and another folder would contain Home Model, View and Controller etc...) instead of the default ASP.NET template. With this being said I quickly realized when I moved my views my controller was looking under the views folder. I fixed that but then my views were looking for the Web.Config and I fixed that by copying the views folder Web.Config into that folder. This is a solution but I want to know if I can point all my views to one Web.Config without having to have them all in the same folder.
Every folder in ASP.NET web application / website can have its own web.config file. Having said that, it is also necessary that the root folder of your application must have a web.config file based on which the application / website will be configured in the hosting environment.
Therefore, if you want to use different settings for different folders, you can place a separate web.config file with settings specific to folder in the any of the application folder.

Does deploy of a pre-compiled IIS site show faster first load times?

Using the asp.net compiler I have compiled a site with aspx pages. The contents of the pages have been replaced with placeholder text and the bin folder now contains multiple App_Web_*dll files. There are also multiple *.ascx.hash.compiled files.
I've copied this folder to the webserver and deployed by creating a Virtual Directory that points to this folder. The site works but I am not seeing any improvement in first load times.
When the first aspx is requested, the IIS asp.net cache is rebuilt in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files. This is as time consuming as dynamic compilation of source files. It almost seems like the site is being recompiled. The layout of the IIS asp.net cache is different from the site folder. There are App_Web_*dll files in the cache folder but different names compared to the site.
Am I missing some configuration to get this working right?

Asp.Net : Is it save to upload and files in web config folder?

Is it good practice to store user's files(images,documents etc) in web config folder ? Is it gonna affect my website anyhow ? Because i do know that it is unacceptable to store dynamic/user's files in the BIN folder. So now i'm trying to establish a folder path to store my dynamic files. The other reason is that my service provider said i'm only allowed to store files in the folder where i store my website because i'm hosting my website on a their shared server.
It's safer to store uploaded files either:
under the App_Data folder
or, outside the website's root folder.
This ensures users can't navigate to the uploaded files.
In your case, your service provider's restrictions mean you should store them under App_Data.
A 'web config folder' doesn't really exist. The web.config is a file that can exist at any level in your website directory structure.
To answer your question: simply create a folder anywhere under your website and store the files there. You can create different directories for each user if necessary. This should not adversely affect your website in any way. But... if you expect hundreds of thousands of files, you may need another solution.

Serving ASPX pages from outside the web root

Currently working on an internationalization project. One of the requirements is to take static files published from a content management system and serve the correct language version based on the locale. Unfortunately the published files are .aspx and include references to master pages and potentially other controls.
If the pages are inside the web root, this is pretty easy. I just have something in global Application_BeginRequest that takes a request for /abc.aspx and rewrites it to /content/[locale]/abc.aspx.
For ease of deployment and a couple of other reasons, I would really like these files to be outside the web root. e.g. site is in "D:\www_root\site\" and content is in "D:\content".
Is there a way to achieve this?
You can create a virtual directory in IIS that points to d:\content.
A virtual directory is a directory name (also referred to as path) that you specify in IIS and map to a physical directory on a local or remote server. The directory name then becomes part of the application's URL, and users can request the URL from a browser to access content in the physical directory, such as a Web page or a list of additional directories and files.

Editing resource files without recompiling ASP.NET application

I'd like to enable the resource files to be editable after deployment. I read this post which suggests that this is possible, but I can't seem to figure out what settings I need to change to enable this.
I have added the App_GlobalResources folder to my ASP.NET 3.5 "Web Application" and added a resource file to this folder. I assume that the Build Action for this file needs to be changed, but no matter what I change the Build Action to, I cannot achieve the above stated functionality.
The App_GlobalResources folder and the resource file are copied into the bin directory. Once deployed, any edits to the .resx file are not being displayed.
Any ideas?
You can achieve this, and I just did it.
Select the resource file in your project. Change the Build Action to content. Make sure that the Copy to Output Directory setting is turned OFF. When you deploy your project, the App_GlobalResources directory and your .resx file will get copied to the root of your web site. You can modify the .resx file and your live site will recognize the changes.
A Web Application project is different than a Web Site project. I doubt you can achieve what you want with a Web Application project. You might check out this post:
ASP.NET Web Site or ASP.NET Web Application?
Resources are generally meant to be static. They are items such as images, strings, and files that your program consumes and can rely on being present, (and therefore can be strongly typed in the case of strings/RESX files). The reason for using resources is simply to bundle them in with your DLL's so that distribution and referencing the resources becomes much easier.
Editable at runtime suggests you might want to use project or user Settings, or maybe a database? If you need to use RESX files you might need to write code to read/write them.

Resources