Publish only edited page in asp.net - asp.net

Whenever I update a small part of my website I have to upload whole website again.
If i upload only edited part it throw me exception.
The way I upload my website:
For example if I have 4 pages (home, register, about me, contact me) and if I update home.aspx, I publish whole website in a local address, and then I compress it with zip format and upload it manually.
Is it possible to publish only updated part?

It is not possible to publish only a part of website, but what you can do is to choose Single-File Assembly build option ,by this you can get single assembly for your page.so intead of updating whole application you can update only the pages you change
read more

What I always do when publish ASP.Net Webform project, I complate it with two steps. Maybe this way suitable for you.
When you use publishing tool on visual studio by selecting Build menu -> Publish, you can choose "File System" as "Publish Method", type your "Target Location", and select "Replace matching files with local copies". It mean the project will publish modified files only.
After publishing have done, Open defined "Target Location" using windows explore and sort by "Modified Date" and just copy newer modified files for each directory recursively to your server.

If you build the website pages into dll. You can not published only the aspx. there are many other dll and compiled files in bin folder, we don't know which matches which aspx.
If you only edited the "view", i mean, the html and markup part of <%%> code, and no code behind (.aspx.cs) change, you can published only this aspx. But remember to set website as updatable in the publish dialog.
I suggest you to compile the aspx into one dll. according to #Buzz 's answer. Then, your aspx files would be only an empty file. All you need to do is upload only one dll to the bin folder.

Related

how to edit a file in an online aspx site?

I'm very new to asp.net ( but an aged PHP developer) ..
I'm now in a situation where I should do some small modification in an online aspx script(using vb.net).
I downloaded the whole site and opened it in visual studio, all the modification I had to do is to make a redirect to another external page after succesful login,I determined the place where I should do my modification inside a file named login.aspx.vb , and added this line in it:
Response.Redirect("My URL Here")
And then uploaded only the modified file again, to get no change at all.
I even tried to modify the success msg that appear after successful login and re-uploaded it to find no change at all ( still showing the old message)
Is there some step I'm missing before uploading the page?
You will need to compile the project, and if using visual studios you can just hit ctrl shift B and it will build the entire solution. Visual studio detects which project in the solution has changed and will compile it. Then do as the other answerer says and upload the .dll file which is a container of your compiled code that will be referenced by the host you upload it to when there is a request for it. (A container is a definite over simplification for more details check:
What is a dll?
In ASP.NET there are two types of projects.
Web application project
Web site project
In the first case, when you edit a .vb file you need to compile it with Visual Studio and upload the generated .dll file created in the bin folder.
In the second case you can edit the .vb files and upload them and IIS will compile them.
Based on what you wrote, you are in the first case. In that case you need to have the project / solution files to make any modifications in the .vb files. If you don't have access to those files you could inject some code in the .aspx or .ascx files.
For example:
<%
Dim flag As Boolean = false
// Write some code to set the flag
If (flag) Then
Response.Redirect("~/default.aspx")
End If
%>
Using <%....%> you can write code to execute when the page starts to render. This is a bad practice since because it has poor performance since the code is parsed and executed at runtime, while the code in .cs files is already compiled.
But if you don't have the project files you could do minor changes with this hacky approach.
Edit: If you are in the first scenario, you need to build the project and then upload its .dll file which is in the /bin folder. For any changes in the code files you upload only the .dll. If you change the .aspx, .ascx, etc files you need to upload those as well

ASP.NET MVC 4 IncludeDirectory from a another referenced project

I'm facing out a strange problem while using ASP.NET MVC 4.
I have 2 "Web Site" projects:
The first named "MyWebSite"
The second named "MyWebSite.Support"
I need to include the scripts under MyWebSite into MyWebSite.Support, so i thought to create a bundle in MyWebSite.Support and to reference that directory (MyWebSite/Scripts) inside that bundle by using "IncludeDirectory"
The problem is that i didn't found a way to correctly do that. It simply doesn't work because the starting path for the IncludeDirectory should be "~", which is the project virtual root path.
PS: If you have another solutions they are welcome!.
I don't even know if it's a good solution (i usually am not a everything_related_microsoft developer)
You could add the scripts as a link to the other project. This will assure you that they are copied when you deploy and you can use them in bundles. To do that, right-click on your scripts folder and select "Add existing item". In the dialog box select the files you want to add. Instead of clicking "Add Item", click on the little arrow next to it and select "Add as a link".
This will not actually copy the files, but include them as a linked file.
This has several advantages:
Files are shared between projects at Design time
You only need to share the files you want, not everything
You don't need any IIS configuration
You can easily edit the same file from each project (without copying it)

You are attempting to open a precompiled Web site

I have a website developed in asp.net. Files have both aspx pages and codebehind files. When I try to open it in Visual studio 2010, I get this message:
---------------------------
Microsoft Visual Studio
---------------------------
You are attempting to open a precompiled Web site. You can view the site, but changes might cause the Web site to stop functioning. To modify a site, it is recommended that you edit the files in the original Web site, precompile the site, and then publish it again.
Do you wish to continue and open this Web site?
---------------------------
Yes No
How to open this website for editting ?
I know this is WAY late but it might be of use to subsequent readers.
First off, Martuza Kabul is wrong. You only need 2 files, the .aspx/.ascx/.master and the relevant .cs (this means .aspx.cs/.ascx.cs/.master.cs)
What has most likely happened here is that somebody has compiled the site and the DLLs are now lying in the bin folder. (If you are as lucky as i am, they're also in source control..)
Here's what you need to do:
Delete the PrecompiledApp.config file
Delete all the non library .dll files in your bin folder (mine were WebApp_122141Xas or something like that, these are compiled codebehind files.)
Look at the first line of your .aspx / .ascx pages - In that control tag - in there is an "inherits" attribute... you will see it has 2 values, delete the 2nd one.
In that same control tag, notice that the Codefile attribute is missing. Add it and point it to the correct codebehind file.
That should be it. Hope this helps somebody.
You have to have CS file to edit the website. I assume that you are trying to open a website which was published earlier using precompiled option.
Pls post type of files in your website for further information.

Can you precompile and merge part of an ASP.NET website and then continue development?

A big part of the web site is precompiled and merged, since it's almost never going to change. The precompiled bits can be replaced in case of updates to the original. I want to continue development of new pages, but when I browse to a new page I get the following error:
The file '/Website/Test/Default.aspx'
has not been pre-compiled, and cannot
be requested.
Is there any way around this?
Edit:
If I remove the precompileApp.config file I get the contents of the marker files when I browse them:
This is a marker file generated by the precompilation tool, and should not be deleted!
Have you looked at the precompile with updatable UI option? This compiles all the source code and resources into a DLL but allows you to continue making changes to your .aspx pages after deployment.
Another option could be to precompile the website in place on the server instead of precompiling it then deploying it to the webserver.
Both options are addressed in this MSDN article:
http://msdn.microsoft.com/en-us/library/bb398860.aspx

How do you update an ASP.NET web application?

Simple question. If you have a compiled and published ASP.NET web application running on a server and you need to update, say, a line in one of the codebehind files. Do you shut down the entire site, republish, then load the site back up? Or do you publish straight to your live site with users still using it?
For myself, place an app.offline app_offline.htm file into the site, then overwrite the entire website with the latest published build.
there are a few options when building a site -> one dll for the site or one per page. if u just updated one line in a code behind, and you have chosen the build option for one per page, then you can just copy/paste that new page dll.
i don't like that method personally. I find it simple to app_offline.htm the site.
If it is a single file and a simple site that uses that app_code folder to store the code behinds, I simply xcopy up the new files. If I use http expiration headers I may need to do some better scheduling to make sure things like javascript files and css sheets match the rest of the site that was updated.
For emergency patches:
If its just a codebehind file, I copy the entire /bin/ out and replace all DLL's (mostly out of habit)
If its an aspx, I just copy the aspx.
For actual deployments, I have an automated system that checks out the code from source control, builds a clean release build, takes the site offline, and then robocopies it out to the deployment target. Its a one click process (Thanks CruiseControl!).

Resources