Often when designing websites static or dynamic, PHP or ASP.Net, Laravel or WordPress, you have to design in a way that if the user hovers an image it gets changed and an alternate image is displayed. This can be easily achieved via simple HTML events. Here is the trick:
<img src="FIRST IMAGE URL GOES HERE"
onmouseover="this.src='SECOND IMAGE URL GOES HERE'"
onmouseout="this.src='FIRST IMAGE URL GOES HERE - AGAIN'" />
It is simple as that.
Click here to read more tips.
If you’ve been developing ASP.Net MVC apps lately you might be thinking of some online or cloud-based app hosting platform available as PaaS for Microsoft technologies especially for hosting ASP.Net MVC apps just like OpenShift, Heroku and other platforms are available for technologies like Ruby, Python, PHP, Node.js and even supporting CMS like WordPress. The good news for ASP.Net developers is that there is a PaaS platform available that you might already know. The platform is AppHarbor. AppHarbor runs over Amazon AWS and has some nice features that I won’t go into the details of. If you are interested in knowing how AppHarbor works you can see their page here.
Regardless of whether AppHarbor provides a decent service, new developers might still face some difficulty in deploying their applications to AppHarbor. Especially, if you are developing apps based on new Visual Studio 2015 templates like MVC. There are different ways to deploy but I would follow the below approach which in my opinion is good and provide auto deployment or in other words Continuous Integration (CI).
What do you need?
We will be using the following tools and accounts.
- Visual Studio 2015 (any edition, I used the Professional version)
- ASP.Net MVC app created from VS2015 MVC template
- GitHub repo for the app/project
- Local git repo for the app with remote repo set as your GitHub app repo
- AppHarbor app
What’s not covered?
Our focus today is the deployment of our ASP.Net MVC app to AppHarbor. Therefore, we won’t be going into the details of how the application is created or its architecture, what’s new in Visual Studio 2015, what is MVC, what is Git and GitHub, and how to connect your GitHub repo to AppHarbor etc. We will assume that you already have all the prerequisites and we will just focus on what problems can we come across during deployment and how to fix them.
- Initialize a Git repo and connect it with your GitHub repo.
- Create the AppHarbor app from your GitHub repo. Whenever we commit/push our changes to our GitHub repo AppHarbor will automatically fetch the latest push and build it. Upon successful build it will deploy the app on its server otherwise it will keep the last successful build. This makes things very easy.
- Create an ASP.Net MVC application using the Visual Studio 2015 MVC template.
- Add the packages folder to .gitignore
- Enable NuGet Package Restore. In VS2015 click Tools>Options and then select NuGet Package Manager and make sure both checkboxes are checked in this section.
- In VS2015 right click on the project and click properties, then go to the Build Events tab. In the Post-build event command line text area paste the following command.
- if not exist “$(WebProjectOutputDir)\bin\Roslyn” md “$(WebProjectOutputDir)\bin\Roslyn”
start /MIN xcopy /s /y /R “$(OutDir)roslyn\*.*” “$(WebProjectOutputDir)\bin\Roslyn”
- Now commit and push your changes to GitHub.
- That’s it! AppHarbor will automatically fetch the latest version changes and build it and you can check your AppHarbor application on its URL.
There are a few things that you need to take care of specially related to security. This MVC app uses SQL Server Compact which isn’t a good option for production-level apps. Secondly, your connection string or password to the database must not be committed to a public GitHub repo.
This post will just give you a smooth start without any difficulties which I faced among other people that you can see in the resources section below.
If you think this was helpful or if I have missed anything please do let me know in the comments below.
Using Response.Redirect in a try catch block will throw an exception “Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.”.
To work around use the overloaded method Response.Redirect(String url, bool endResponse) and pass false to second argument. The detailed reason can be found at http://support.microsoft.com/kb/312629/EN-US/.