I'm a little confused, since a day or 2 i've been programming with visual studio 2013 web express. i've made a C# web form (.aspx). i used to program normal html/css in Adobe Dreamweaver.
But unlike a normal .HTML document i cannot find a file to just click and open in my browser. and so i do not know how to upload my project to my hosting server. when i debug it, it shows up in my browser and it tells me it is the file with .aspx extension but when i try to manually open this file it just tells me there's something wrong with my page (incorrect code etc.)
Anyone can tell me how i do this? could not find a solution in google so i thought i'd give stackoverflow a chance :)
Thanks!
Gr.
First off, a website programmed with ASP.Net requires Internet Information Services (IIS) to run.
Visual Studio has its own built-in mini version of IIS for development, but to deploy to production you'll need a Windows Server with IIS. You should check that your hosting provider supports IIS before you do anything else.
Assuming you have IIS running, and you've configured a website in IIS with an empty directory, ready to host your project there are a couple of different options you have for deployment:
Just copy everything in the website to the server (all files & folders). This is simplest, and allows you to tweak things on the fly, but is the least secure.
Use Visual Studio's packaging and deployment utility. Not much to say here, other than read the manual.
The .aspx pages, .ascx controls, the bin folder with your .dll files, web.config, App_Themes, App_LocalResources, etc. And then you'll need to set up a new web site on IIS.
Related
I am a newbie to asp.net. I recently publish an asps site from Visual Studio using C#, but I realised that the scripts I wrote for the buttons, links, etc to interact with my database on local machine is missing when I publish the pages.
Do I have to rewrite the code for the pages now on the web host?
Your advice is needed.
Thanks
It's really hard to answer such a question, no details, no code, and things disappearing mysteriously. However, given that you're newbie and from the description that you have, I will try to give you some tips that will hopefully set you in the right direction.
Firstly, I don't know exactly what you mean by "script", so I will assume you're referring to what is called code-behind. ASP.Net is different from many other web application frameworks in that it is compiled. So you have the front-end of your aspx pages which has a mixture of HTML and ASP server-side controls, and then linked to each aspx page you have an aspx.cs code file for the code-behind.
Now, when you're ready to upload your project to the hosting, you should use the Build => Publish menu. This will compile your project in Release mode. All the aspx.cs pages will be compiled into a dll, so you will not see them among the file that are uploaded to the hosting, and you cannot modify them. The aspx pages are typically not compiled (although you can configure that), so you will see them and you can still modify them.
As for the database connection, when you're writing your code, you typically connect a local database on your computer. You should have the connection string in the web.config file in the root folder of your project. However, the connection string for the hosted database is likely to be different, so make sure you have the correct connection string for the hosted database in the web.config before you upload your code to the hosting.
I think this will answer your question. It's a setting on a file level, available on properties (F5) for the file:
Visual Studio 2010 Web Publish missing a file
Once you set it and republish, the file will show up in the publish location.
I was compelled by work to upgrade from Visual Studio 2010 to Visual Studio 2013. In VS 2010, I used the built-in host for viewing .net apps locally and everything worked just fine. Visual Studio 2013 dropped support for the built-in host and compels everyone to use IIS Express.
My trouble is that IIS Express won't serve up "[anything].aspx" no matter where in the folder tree of the project it resides. I created two test files in the root of the project: HelloWorld.html and HelloWorld.aspx (c#) and made both to simply show a page saying "Hi" with the asp.net file showing the current date and time. I then copied these two test files into an arbitrary folder in the project. After building the project (unnecessary, I know), I did a "View in Browser" for all test files. In all cases, the HTML files displayed properly. The aspx files cause a "HTTP 400 Bad Request" / "The webpage cannot be found" error.
I've prowled Stack Overflow and Google and read about some near-misses but ultimately came up empty for this specific problem. I'm hoping this is a simple configuration issue, but the answer so far eludes me. Thanks in advance for your kind assistance!
Edit:
Thanks to Lex Li's suggestion of using the Jexus Manager to see what's going on with the IIS Express configuration, it shows that zero apps are assigned to any of the default application pools. Correspondingly, when clicking on the home of the website in the Jexus Manager, the .Net section of the website is absent.
Edit #2:
The web app is assigned to one of the default IIS Express app pools: Clr4ClassicAppPool.
Sound weird, did you try open the iis express xml applicationhost.config and check there the mime type or the application pool settings?
I developed a site in asp.net using C# as the language.
I have debugged it and no more errors can be found and can also view the page from a browser.
I would like to host this site and direct a client to it for demo purposes but am having a problem each time I publish my site. The publishing only does away with all my .aspx.cs files but I don't see any .exe file that I can install or send to my hosting provider.
I would like to know if this what I am experiencing is normal or there are settings I need to do in my visual studio 2013 ultimate edition for these tasks to be performed?
Kindly advise me on the way forward
ASP.NET applications (not "ASP.NET websites") are compiled into a .dll file in your bin folder, which is then deployed on to the server.
Your .aspx/.cshtml1 files reference compiled classes and types contained within this DLL, thus eliminating the need for source files.
There won't be any .exe files, you need to deploy your project to a web server, like IIS. Check out this link.
I'm very new to IIS7 and somewhat new to C#. My project right now is to use C# and IIS7 to create an interactive website with various clickable items and features. The C# programs are written and working properly, however I honestly do not know much about IIS7 despite trying to research it for a good amount of time.
My question is, how do I integrate C# scripts into ISS7 so that the website can be hosted with said scripts running smoothly within it? In other words, how do I combine the powers of ISS7 and my C# code to make a website? What must I do within ISS7 to utilize my C# code?
I've already "created" my new site within IIS7 and given it the appropriate bindings. I'm just not sure where to go from here.
I realize this may be a broad question/answer, so pointing me to where information on this topic can be found would also be greatly appreciated. I've searched through the official IIS website without much luck. Thank you.
It depends on what kind of code you want to run. The best start might be a straight forward web project, and not web services/web api.
Create a new web site project in visual studio, and hook it up with IIS in project properties-> web -> uncheck "Use IIS Express" and click "Create Virtual Directory". When you build the solution next time, it will be "deployed" to your local IIS.
A virtual directory maps to a physical directory on a computer. The web application will be running on your machine. If you have IIS on a web server that is not your development machine, then you have to deploy your web application to this server.
You might find this usefull: How to: Create IIS Virtual Directories in Visual Studio
The relationship between Visual Studio and IIS is that you can create virtual directories from Visual Studio. This means that when you visit localhost/MvcApplication1, IIS serves you the web application that is mapped in C:\Users\<Username>\Documents\Visual Studio 2012\Projects\MvcApplication1
I have an asp.net application that i am modifying. I setup visual studio 2010 to publish to are development server which is running windows server 2008 RC 2 (dont think it matters). I added a new webform to the application through visual studios "add new item" feature and it works on my local computer. When i publish to the server, it starts to throw cryptographic exceptions because its trying to access a .p12 file in order to send apple push notifications to an iphone device. I thought it was something wrong with the certificate at first so i added print statements to the code and noticed it is trying to access the new page at the file path on my local machine instead of the file path on the server. Does anyone have any ideas on why its doing that? Is there a way to make the file path relative to the project?
You have to use MapPath("{relativePath/FileName}") . This will return a physical path.
filename = MapPath("/images/logo.jpg")
Would something along the lines of "C:\inetpub\webroot\images\logo.jpg"
Server does not matter. The file was added with an absolute path. Not sure why and don't have the time to research.
How is the site set up on your debug machine? Are you using IIS or the ASP.NET development server? Not sure if this makes a big deal, but switching to IIS and better mimicking production often solves these little snit type of errors. To switch, add the folder to IIS, then remove the project and re-include with the HTTP path instead of the project folder.
If local IIS is not an option, or you already have done that, I would do a search for the path in question and alter it there. If you find no results, this could we be embedded in the solution file some how.