The HTML generated on a web page is, by definition, publicly available. It must be accessible to the browser so that it can display the page correctly. You will not find a reliable solution to hide the view source setting in browsers.
To explain the basics a bit:
When you create the page, you write the markup in your .aspx file and some C # source code in the .aspx.cs file. C # code is server-side code, which means that it runs on the server (unlike, say, javascript, which runs directly in the client browser, on the client side).
When a page request is executed, the ASP.NET engine executes the server-side code and also executes the asp tags that you wrote on the .aspx page (for example: <asp:Button runat='server'... /> ). Then it spills out HTML code (this is a very simplified version of what is actually happening).
The client browser only ever receives HTML (and it will not see C # code or any asp markup code that is used to create your page).
As I said, the HTML created is and will always be publicly available. You cannot do anything to securely hide it.
source share