Web application - automatically include files? - c#

I am running a CMS as an ASP.NET WebApplication and want to automatically include all files generated by the CMS in the project folder to be included in the project.
By default they are excluded, and finding them by hand and including them every time a new file is created is annoying.
Is it possible to include new files in the web application folder by default?

Web Site Projects work that way, however I am not sure why you would want CMS generated content in your source code repository.

Related

Adding new project to asp.net core solution

FirstCoreApps is a .net core empty web application..
when I am trying to add new web project CoreMVC it is adding a directory to FirstCoreApps as well, as shown in the screenshot.
I am very new to Asp.net core, please let me know what is the reason and how to deal with this....
When you created the second project, you seem to have accidentally created it inside of a folder in the first one.
This can happen if the solution (CoreApps.sln) file is in the same directory as the first project file (FirstCoreApps.csproj). The dialogs then probably suggested a directory that you should not have used.
Since the new project model automatically includes everything in the folder of the csproj file, the files of the second project automatically become part of the first project.
When creating new projects, be sure to check the "Create directory for solution". This creates a folder structure where the .sln file is created in its own folder and ever project in its own sub-folder.

updating published asp.net website

I just publish an asp.net website then i made changes in its source code i added two .aspx files and then publish it again
The question is what I need to make this changes take effect on server. Do I have to replace all files or i can just add specific file?
I'm trying to add two aspx pages to the site that already exist on the server
and want to know which file i have to add beside the ordinary aspx file to take effect on site
Thanks
This depends on how you are deploying your code. Are you using the precompile option before publishing or just publishing with pre-compilation.
If you are just publishing then you can just replace the .aspx and aspx.cs files and the site will dynamically recompile.
If you have pre-compiled it then you are probably only left with .dll files and .aspx files so you would have to deploy a new copy of the .dll file for your site and the .aspx files. MSDeploy replaces the entire site by default.
If you have only changed the aspx file and not the code behind it is enough to publish those two files and on the server. If you have changed the code behind as well you also need to publish the dll files, in that case it's probably easier to replace all of the files.

App_Code and server

I'm having a "tiny" issue with my App_Code folders.
I'm learning ASP.NET and, therefore, ordered a webserver with the support of ASP.NET 4.0. I'm using Visual Web Developer to program my webpages. When I upload my website to this webserver everything runs fine.
However, if I then add another web project to my server, my App_Code folder gets all messy. The server wants all my class files in the App_Code folder in the root. Is there any way I can create subdirectories in my App_Code folder or something to keep my projects organized or am I missing the point here?
You should take a look at codeSubDirectories in the web.config
Alright I found a solution to my problem. Although most of your answers might work aswell, this proved to be the best in my case. I created a subdomain and threw all files into that folder and it worked fine.
You should try to avoid using the App_Code folder for your own stuff, especially if you're using a web application project.
Whenever you convert a website to a web application project, the process actually renames your existing App_Code directory to Old_App_Code.
See Here, even though this is specific to converting .net 2.0 apps, I believe it still holds true in 4.0 since converting a 4.0 app does the same thing.:
VERY, VERY IMPORTANT: Because ASP.NET 2.0 tries to dynamically compile any classes it finds under the /App_Code directory of an application at runtime, you explictly DO NOT want to store classes that you compile as part of your VS 2005 Web Application Project under an "app_code" folder. If you do this, then the class will get compiled twice -- once as part of the VS 2005 Web Application Project assembly, and then again at runtime by ASP.NET. The result will most likely be a "could not load type" runtime exception -- caused because you have duplicate type names in your application. Instead, you should store your class files in any other directory of your project other than one named "app_code". This will be handled automatically by the "Convert to Web Applicaiton" command. This command will rename the folder Old_App_Code.
If you have access to a hosting control panel it's probably best to configure your hosting environment with a virtual folder for your second website and run it from the sub folder, e.g. www.example.com/project-b. The first site can still be running in the root folder, e.g. www.example.com.
So both sites will essentially be isolated from each other (just like they are now isolated as two separate projects in Visual Web Developer Express). And both sites have their own App_Code folder (and web.config file).
If you don't have access to a configuration panel, most hosting providers are willing to add a virtual folder for you, since it's really not a special requirement.
The virtual folder should show up as a regular folder in your FTP folder, usually inside the www or wwwroot folder. Now you can copy your project files into that folder.
Take care to use root-relative paths for URLs in your second project, so all links will work even when the website is run from the subfolder. Root-relative URLs look like this:
<asp:HyperLink runat="server" NavigateUrl="~/Default.aspx" />
<asp:Image runat="server" NavigateUrl="~/images/logo.png" />
This will automatically go to www.example.com/project-b/Default.aspx and www.example.com/project-b/images/logo.png when the website is deployed in the virtual folder.
If you need to re-use code from one site in the other, it's typically best to move such code into a separate Class Library project type, and then add a reference to that project to each website project (right-click the website project, choose Add reference..., then select the Projects tab and select the Class Library project).

Error: Could not download silverlight application. Check web server settings

Developing a silverlight page in already existing web application for previewing video files. When I create a asp.net application locally and add silverlight application on the solution it works perfectly. But while I am trying to include into already existing project it throws this error. I have not deployed into the IIS. this happens while debugging.
Check the path to your xap file in your webpage. It should be something like:
/ClientBin/my.xap
Also ensure that your xap file is actually in the ClientBin folder. In the web application Properties, choose the Silverlight Applications tab and add the silverlight project to the list.
Although probably not applicable in your case, this can also occur if you are using iis and haven't registered the correct mime type for .xap files. It should be set to application/x-silverlight-app.
This is little same with another answer, but I give my detailed solution with image of setting.
In my case, one of my aspx page will load Zip and Xap files under ClientBin Folder, normally it'll load 20 Zip/Xap files under ClientBin\,
But I found that when building/publishing the project, the Zip/Xap files are NOT output to ClientBin\, that is ClientBin folder is nearly empty.
So my solution is to let the Zip/Xap files output to ClientBin\, to do this, the setting way can see this article:
https://social.msdn.microsoft.com/Forums/silverlight/en-US/d8e2c92a-4b31-4e4b-a440-4960a8d475b4/how-to-generate-xap-file?forum=silverlightstart
Besides here is the screenshot of my setting, that is Right click at your Silverlight project > Properties > Silverlight Application, and you can click the Add button to add content,

Dynamic Data App_code directory - where is it?

i try to learn learn Dynamic Data Entties . i see some sample about it. they try to teach some codes in App_code. i really want to learn where is my Ap_code?
Web Applications do not use the App_Code folder, only Web Sites. If you want to use the App_Code folder create a Web Site instead of a new Web Application.
If you want to use a Web Application you can place the .dbml file anywhere, you'll just have to fully qualify (with namespaces) the DataContext wherever you want to use it (ex: in the Global.asax file).
It seems it is not possible to create the app_code folder. Take a look at the bottom of this page in the community content part. There are a lot of people with the same problem.
SOLUTION: add the .dbml to file root of the site
As mentioned above, a web app project does not create an App_Code folder by default. You can create one using the solution explorer though if you want - right click on web project, new folder..., name it App_Code.

Categories

Resources