Hiding Sourcecode on IIS Server (ASP.net) - asp.net

I have a question about hiding or encoding the source code on a server which runs IIS.
At the moment the source code is available and visible for all users who are logged into the server where the IIS Server is running.
Is there a way to hide the Code (encode) with Visual Studio or any other software?
I think the aspx (or *.html) web site code can not be encoded but (for example) the *.vb code sites should be able to encode.

You can simply Publish the website
Build Menu => Publish Web Site
So the code behind files (*.aspx.cs) will get converted to dll(Bin/*.dll) file.
Refer this: Walkthrough: Publishing a Web Site

When you are ready to put your project live make sure that you.
Publish it.
When you publish it that you tell it to compile your code into a single library or code behind files.
If you want to protect your html as well then you should not select to make the site updateable.
These steps will protect your code but as for your web.config file you will need to look at some other articles on securing its info.
If you can, I would recommend ensuring that only the authorized people have access to the server and/or the code base running on the server. If that is the case then you should be ok.

Go to Build menu---> Click on Publish the Website.
then a folder get created on the base folder. and the encoded files are available there. That can be upload to the FTP account, then third party can't see the source code with the browser.

Related

How to open the starting file of an ASP.NET Core Razor Pages app?

I have a basic question so apologies in advanced but I have been googling for hours and not been able to find the answer. I made an ASP.NET Core Razor Pages app and deployed it to a folder (which is in a network, it's basically our staging environment) and now need to know how to access the index page in the URL. I followed this doc on how to publish the app into a folder: https://learn.microsoft.com/en-us/dotnet/core/deploying/deploy-with-vs?tabs=vs156 (I chose the Self-contained deployment without third-party dependencies option) but now how do I access the index file?
For example if this is the URL: https://testing.com/FolderName
And the app is in the 'FolderName' folder what do I need to follow up next in the URL to open the app? Inside the FolderName folder there is wwwroot folder, appsettings.Development, appsettings, the .exe, a .pdb, and a web.config. So how do I access the app in the web? I also tried copy/pasting the files and navigating to index.cshtml but didn't work either.
Any help would be greatly appreciated. Thanks guys.
Razor Pages are not routed based on the file system (like PHP).
You start the Web server (by opening the exe) and navigate to the URL where the Web server tells you it's serving the app (in the terminal you should see a line that says "Listening on https://your_url:port...").
The index should be the first thing you see when you navigate there.

Using class (.cs) files in simple web site.

Alright I am a bit of a newb when it comes to ASP.net. I am used to PHP.
Anyway, I am working on a website that is connected to my server via ftp. Everything is working fine, except I just added some classes in the App_Code folder. I cannot access those classes when I go to the page on the web.
I was researching a bit and everyone said I needed to publish the website. Well I did that, and it completely broke. I had to restore from a backup and lost a lot. My own fault though.
The classes work if I am using them on a local web site, but not on the web. Any guidance here? I've tried moving the App_Code folder around with no luck.
the web server doesnt directly execute a .cs file like a .php file. a web server has registered handlers associated with a file extension. when a request arrives, the extension of the file is used to find a dll to process the request. the asp.net web pages model is an easy onramp for people coming from php. http://www.asp.net/web-pages

Hyperlink to EXE file

I have created a simple windows .EXE that copies files from one location to another on a target computer.
However, on the website that I'm testing this on, I created a hyperlink:
Here is the download.
However, when I click on the link, it attempts to start CustomApp.exe which is not what I want to happen. I want to prompted to accept the user file, then run it.
Is this something I need to configure on an IIS 7 machine, or in my ASP.NET page?
It's the way your server serves that mime-type. Might have to configure it differently or serve the download using a php/asp.net page and edit the headers.
Some more explanation on how to do this in asp.net from asawyer:
http://msdn.microsoft.com/en-us/library/dhy78ycf(v=vs.71).aspx

ASP.NET MVC - Website paths

I am using a 3rd party component which creates settings files based on hard-coded file paths i.e. they are compiled into the DLL e.g.
%APPDATA%\Vendor\Settings.ini
I have created a few console/service applications that use this and work very well. However, I am now trying to use a similar approach via my ASP.NET MVC web application and the settings file never seems to write out!
Usually if the application is running under my acconut for example the file would be written to somewhere like:
C:\Documents and Settings\James\Application Data\Vendor\Settings.ini
So I thought if the website AppPool was running under the same account the file would be saved to the same place....However, it never appears. The account is an admin account running under Windows server 2003.
Any ideas?
Thanks.
Have you checked to see if the settings file is created in the App_Data folder in the web application? If not, could you put an existing settings file there and see if it uses it?
It's not about the webpool account, it's about guest user's account.
Go to the properties of your site in IIS, Directory Security and in the anonymous access click on the Edit button, there you'll see wich account is been used when someone access your site.
Couldn't find a solution to this, so I decided to develop a local WCF service (which would create the settings file in the correct directory path) and just accessed it via my web application.

Enable downloading from my web site

I have a web site application and i need my web site to allow user to download a setup file from my web site how can i do this ?
I Asp.net2.0 _ C#.
Place the file somewhere within your website and make a link to it:
Click here to download
If a simple links does not work, please update your question with a description of the problem you are facing. You might have to configure your web server to serve files of type MSI or EXE (whatever your installer is packaged as).

Resources