Source control strategy for specific folders within CMS-generated site - asp.net

I have an ASP.NET website where most of the pages are generated and published via a CMS system. This includes static HTML, CSS, ASPX, ASP, images, etc.
However, we have some user controls and pages that are managed by a separate dev team. These files live under the same web root but are not managed in the CMS. These files are limited to a few files and folders under the web root:
/bin
/user-controls
/custom-aspx
/web.config
(everything else under "/" is CMS-generated)
We don't want to check in all the CMS-generated items into source control (TFS in our case), because those files are constantly changing and versioning is managed within the CMS.
How should we handle source control for the directories listed above? Should we just check those in separately?

I see 3 options:
Checkout your version controlled file tree to root and add an ignore parameter for all CMS generated files (assuming they have a set of extensions that make this feasible).
Checkout each of the directories (/bin, /user-control, ...) separately to sub-directories of root, and make sure that no CMS generated files are written to these directories.
Checkout your version controlled file tree to root and just don't run svn add on any of the CMS generated media.

Related

How to host GitHub repo on Nimbella

How can I host my github repo on Nimbella .
I have created a website using HTML,CSS,JS. which I have hosted on GitHub pages. but I want to host it on Nimbella.
https://nimbella.io/downloads/nim/nim.html#adding-static-web-content
Adding static web content
To add static web content to a project, add a directory called web as a peer of the directory called packages. This directory should contain files whose suffixes imply well-known mime types for web content, such as .html, .css, or .js.
Note: JavaScript files in static web content are not actions but are scripts intended to run in the browser.
The web directory can have subdirectories and can be built by website builders or other tools.
Like an action directory, the web directory may contain .include or .ignore to control what is actually considered web content, as opposed to build support or intermediate results. For more information about .include and .ignore, see Multifile actions created with autozip.
The web directory also supports integrated building, just like an action directory.
Here’s an example of a project with modest web content, populated by hand. For simplicity, the actions of the project are not shown.
example3/web/chatroom.html
example3/web/chatroom.css
example3/web/runner.js
example3/web/favicon.ico

Where to put ~/Areas/../Views/xxx.cshtml specfic js files in ASP.NET

I am porting a website from MVC4 to ASP.NET Core 3.0
My major views have view specific complex script files which I used to put in the /Areas/AreaName/Scripts/ directory and access them with something like.
I used to put these in a script directory in the area.
<script src="~/Areas/AreaName/Scripts/*ViewName*Scripts.js"></script>
Doing that now results in a fully dedicated file name like
<script src="C:\Users\..\..\..\..\*ViewName*Dripts.js"></script>
Which is clearly not the way to go for obvious reasons.
Do all scripts including view specific scripts now go in the ~/wwwroot/... directory
Static files are stored within the project's web root directory. The default directory is {content root}/wwwroot . The simplest way is create area folders in wwwroot\js , and add area specific js flies into corresponding folder . You can also serve files outside of web root(/wwwroot), see document for code sample .

mvc which files are needed for deployment?

I've been working with webforms and recently started to work with mvc. With webforms, when we use to push to the qa/prod server, we alway copied over the files. leaving behind the .cs files, so just the .aspx, bin folder, along with associated js/css files would go.
with mvc, if we are copying the directory over from our pc (where we develop), what files are needed, do we need the .cshtml files for example? I just want to avoid having to push all the files if they are not needed.
They are definitely not all required. What you are going to want to do is setup a way to publish, this ranges from doing a "bin deploy" to feeding in ftp settings and using a "single click deploy" approach.
What it all boils down to though is this. You will need
A bin folder with every relevant .dll
A content folder with relevant images and css files
A script folder with relevant .js scripts
A views folder with nested folders for views with relevant .cshtml files
A .webconfig file in the views folder and also one at the very root
The packages.xml file at the very root
The global.asax file with markup pointing to the application starting in global.asax.cs
What this excludes is every single .cs file. These will all be composed into your projects .dll. So if you are developing FunWebApp, then all your c# will be rolled into FunWebApp.dll in your bin folder.
Use the Visual studio "Publish" option available on your UI Project. This will generates all the required files you neeeds includes, bin folder, Views folder(which will have the .cshtml files),Content folder,Script folder, Config file(web.config) etc.
Right click on your project and select "Publish". You will be shown a wizard where you can define what kind of publish you want. You have different options like FTP, File system etc.
You will not see the Controllers folder / Other class files because code inside that folder is compiled to your assembly which is in the Bin folder

How to get ASP.NET website precompilation to exclude a certain folder

The several different environments (e.g. live, demo etc) of my web app are differentiated by config settings in a folder called EnvironmentConfiguration. Whenever I update one of the sites, I delete the EnvironmentConfiguration folder from the precompiled site before copying the website files over (i.e. in order that the EnvironmentConfiguration folder in the deployment location is not replaced).
Just to save mistakes, is there a way I can get Visual Studio not to produce the EnvironmentConfiguration folder when it precompiles the site for me?
You could try a couple of things.
1) Right click on the folder in the solution and select exclude from Project.
2) Look at each of the files in the folder and set the BuildAction property to 'None' rather than 'Content'

How might i setup my ASP.NET project to find my files?

edit I do not want to redirect pages, specific files etc. I would like to change the path where images, videos and other media are stored from the root source directory to the directory of my choosing. In this case c:/dev/prjfiles/prjname/public (c:/dev/prjfiles/prjname/ is my working directory) and i except when 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 looking at how to set virtual directories and etc. I cant figure it out. Thus the bounty. I am generating the html, i am not writing asp:image runat="server" etc i am pulling data from a DB and outputing the html. The part that is still a WIP is the code that handles POST request. The html already exist but i cant have hundreds of files in site.com/here pollution my source directory (c:/dev/trunk/thisprj/thisprj/where my .aspx files are and i do not wish 500 .png/gif/jpg here)
I dont know how asp.net environments are usually set up. I am assuming i have a root path that is not available from the web, a bin/ where i may put my asp.net dll and a public where i stick in any files i want.
I would like to have my project files seperated from everything else. My JS, css and image files are in prjfiles/prjname/public with my sqlite db in prjfiles/prjname/ and extra binaries in prjfiles/prjname/bin.
The problem comes when i run my app and try to load an image. Such as /cssimg/error.png. My project does not find resource in my /public folder and i have no idea how to make it find them. How can i set my project up so it does?
NOTE: I set the working directory path so its at prjfiles/prjname/. In code i write ./bin/extrabin.exe and db.sqlite3 which access the files properly.
You might want to watch the getting started videos for ASP.NET
http://www.asp.net/get-started/
EDIT: More info added
As #Murph suggests, your assumptions are incorrect.
IIS takes care of blocking HTTP access to any important files and folders like your *.aspx.cs, and *.cs in the App_Code, any DLLs, anything under the App_Data directory and the web.config.
Content files, such as *.html, *.css, *.js, .gif, .jpg, .png are all served in the normal manner.
In this way, there is no need for a "public" folder.
I dont know how asp.net environments are usually set up. I am assuming i have a root path that is not available from the web, a bin/ where i may put my asp.net dll and a public where i stick in any files i want.
This is wrong assumption!
You have a root folder, which IS available in public. You set IIS or ASP.NEt Development Server to this folder.
(optional, but always needed) You have a web.config file in this root folder for configuration
You have a bin folder for your assemblies (each page or user control "include" compiles to a class)
(optional) You have App_Data as default folder for file-based DBs and/or other data files (say XML storage, ..)
(optional) You have an App_theme folder for styling and images. Read about ASP.NET themes.
(optional) You can add App_Code folder if you want to add classes to be compiled by the server.
You can create folders for scripts, etc...
Normally for complex logic, etc.. you create in a separate project outside the root and reference the result assembly in the bin folder.
Seriously, you cannot do ASP.NET work without an IDE or a manual. Visual Web Developer 2008 Express IDE is free and http://asp.net has tons of resources for getting started.
I don't know if I got the question right, but maybe you could try the <BASE> HTML tag.
HTML <base> Tag
"Specify a default URL and a default target for all links on a page"
There's a nice and simple example at W3Schools, check it out.
The negative side is that you need to put a <BASE> tag in each page you want.
It sounds like you should be able to create a virtual directory to do what you're asking -- but it's a very non-standard setup.
Keep in mind that IIS will prevent users from downloading DLLs and other project-level files, so you usually don't need to partition them off in a separate layer.
For example, just have a cssimg folder at the top level of your project, and skip the whole public folder thing.
I see where you're coming from. ASP.NET projects are set up a little differently from how you're treating them, but you can make them work like you want.
The root of an ASP.NET project IS publicly accessible. When you created your WebSite within Visual Studio, it created a default.aspx page right on the root. Are you hosting in IIS? If so, it's set up to serve up default.aspx by default. But I digress.
Here's how to make it work like you want (mostly):
Create a WebSite, then right-click the site and add a folder named "prjfiles". Right-click that folder and make another named "public". Create another subfolder of that one called "cssimg".
Now, if you want to use the image you mentioned, you'd reference it like this: "~/prjfiles/public/cssimg/error.png" (pathing starting with the root) or "./cssimg/error.png" if you're coming from a page in the public folder (relative pathing).
Really, though, you're doing too much work. Here's how to make it work with less effort:
Create your WebSite, right-click the project and add a folder called "cssimg".
Treat the root as you would the "public" folder- put your pages right there on the root or in subfolders, as needed. You can reference that same image file like this now: "./cssimg/error.png" (relative) or "~/cssimg/error.png" (start from root)
There's also another way to tell the engine where to look for resources, but it's for your css files. Inside the "head" tag, you can add a "style" element (with type="text/css") and inside that you can add something like this: #import '<%= ResolveUrl("~/prjfiles/public/cssimg/styles.css") %>';
Good luck!
If I correctly understood your problem, you're trying to find files which aren't physically stored on a filesystem folder, or stay on a different folder. You can deal with this problems by implementing a UrlRewrite mechanism.
I suggest you to read URL Rewriting in ASP.NET and, after, to take a look into this implementation: A Complete URL Rewriting Solution for ASP.NET 2.0.
If I understand all this correctly (please comment with any correction) right now all your files are together in the root directory and you use <img src="/img.png" /> and it works.
If this is the case, make another directory in the directory the images are in, say call that directory images and put the image files there. now use <img src="/images/img.png" />.
Done.

Resources