2013-04-11

Hiding the ASPX markup when publishing an ASP.NET Web application

There are times that we need to hide the markup source from the published ASPX files. We have an option for that in the Visual Studio 2012 Update 2.

1) Right click on the web project from the solution explorer and choose Publish…

1

2) In the Publish Web dialog box, create a new profile (Or update an existing profile) and press Next > (Or choose the Connection tab). From there, choose your publish method (I’m using File System) and press Next >

2

3) In the Settings tab, expand the File Publish Options and tick Precompile during publishing.

3

4) Then click the Configure link next to Precompile during publishing option. It will open up a window shown as below. From there, un-tick Allow precompiled site to be updatable option and click OK.

4

5) Now you are done! Click Publish and it will publish the project. If you look in to the source code of ASPX, you will see the message “This is a marker file generated by the precompilation tool, and should not be deleted!”. But you can’t see the source code. If you look in to the bin folder of the published project, you will see additional files (Extension with .compiled) which are responsible for mapping the assembly code in to ASPX files.

For visual studio 2010 and Visual Studio 2012 (Without update), you will have to install the updates as describe in this link.

11 comments:

Anonymous said...

>>create a new profile (Or update an existing profile)

How can I create a new profile? And pls, tell me I don't need to create an stupid Azure account in order to release to a Filesystem ...

thx

Ruchira Gamage said...

You can create a profile in the first step (Click on the Profile tab). And you don't need any Azure account to publish to the file system. Here the file system refers to your local PC.

PHP Web Application Development Ahmedabad said...

Hey! I just would like to give a huge thumbs up for the good data you will have right here on this post. I will likely be coming back to your blog for extra soon.

- Website Design Company Ahmedabad | Website Development Company Ahmedabad | SEO Company Ahmedabad

Gaurang said...

Nice information to have.
Thanks man.

Hamilton Sellers said...

Nice post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store.

Anna Roy said...

I was really searching for such a nice post...I really like to read such helpful blogs. Keep sharing more.
Mobile Apps Development USA

Niral said...

how to create new profile in visual studio 2010

Ruchira Gamage said...

In Visual Studio 2010, you have to install the updates. Please refer the last part of the article. Also see the answer I gave for the first comment here.

Web Design Company India said...

Its really essential information for people who are the beginners stage of ASP.NET application development.I really grateful to this blog for providing this one.
Web Design Company India | Web Design Companies

Anonymous said...

its really good but i want to know that if i publish a website project and after publishing if i want to change some file or upgrade my project that i can do it or not

Ruchira Gamage said...

Yes you can but not directly on the published files. You have to do the changes on your source files and then re-publish it.