Monday, July 24, 2017

Dynamic Configuration Settings in ASP.NET Core

I read the great article about the configuration of ASP.NET Core web application - Strongly Typed Configuration Settings in ASP.NET Core. As for me, it is better than access via dictionary's keys but it is always boring to create another POCO classes. I prefer to use a dynamic object. And it is easy to replace POCO class with dynamic.

Monday, August 22, 2016

TFS 2015: deploy website to IIS without installing extra add-ons to TFS

Recently, I started to keep my sources under TFS 2015. After moving our work items I have time to pay attention to new build. Everything looks pretty simple until I tried to deploy my website to local IIS. I have found pretty simple article how to do it - Deploy ASP.NET apps to domain-joined machines using WinRM. But this way was closed for me because I didn't have permission to install add-on from the market on TFS Server. So I came back to the old and proven method with MS Build. My parameters for MS Build look like :

/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=RemoteAgent /p:CreatePackageOnPublish=True /p:DeployIisAppPath="Sites/Stage" /p:MsDeployServiceUrl=10.XXX.XXX.XXX /p:username=DOMAIN\MyUserName /p:password=MyPassword

But I didn't want to store my password in build's configuration. So I looked into TFS variables for this. After small investigation I modified a bit MS Build string:

/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=RemoteAgent /p:CreatePackageOnPublish=True /p:DeployIisAppPath="$(SiteName)" /p:MsDeployServiceUrl=10.XXX.XXX.XXX /p:username=DOMAIN\$(User) /p:password=$(Password)

And added SiteName, User and Password variables: 

Pay attention, that I set checkboxes at "Allow at Queue Time" section - it shows parameter in the dialog window during queue and set secret for Password variable. But you can't clear this field and turn off secret - in this case a developer who starts a build has to enter own credential.

So in such simple way, I added the possibility to deploy website without adding new add-ons to TFS.

Saturday, July 6, 2013

Migration to ASP.NET MVC 4: Deployment.

We are developing ASP.NET MVC application. We are using a latest version of the frameworks. So I need to update a software after each framework's upgrade. It easy to do on the developer's machine: you can use web or standalone installer or nuget package.
Usual I used to run installer on the server for the previous version of ASP.NET MVC. But I noticed that installer for ASP.NET MVC 4 contains SQL Express Server and Visual Studio Express 2012 for Web. They are definitely not tools for the server's PC. I carried on with googling and found out that ASP.NET MVC 4 doesn't need any extra library in GAC. It requests .NET Framework (4 or 4.5) on the server and it all.

Tuesday, May 14, 2013

Developing ASP.NET MVC 4 Web Applications - passed.

I have successfully passed Exam 70-486: Developing ASP.NET MVC 4 Web Applications.

I used next sources for preparations:
From the other hand I filled problem with questions related to Azure and CSS. At least first one is topic for develop.

Sunday, March 24, 2013

10gen: M101P MongoDB for Developers - has been completed

I have successfully completed, with distinction, M101P, MongoDB for Developers (Python). My score puts me in the top 6% of all students who registered for the course.
My final grade: 95%.

Monday, July 16, 2012

How to force to update JavaScript and CSS files after deploying new version of ASP.NET MVC application.

Usually after each deployment my ASP.NET MVC (Razor view) site I have a little mess with cached JavaScript and CSS files. Sometimes user's browsers show unappropriated view or some client functionality doesn't work.
Yeah, it is very easy to fix - just clear browser cache or reload JavaScript and CSS files (press CTRL+F5). But I want user to avoid this annoying action moreover not all users are so familiar with PC to know this trick.
My friend Mykhailo found nice solution for this. If I add parameter to JavaScript's url and will change parameter's value after each deployment. Browser will recognize it as other script and will update file.
So now I should add something like "?v=xxxx" to all links of CSS and JavaScript files in my project and keep in mind it for future links. Looks not really smart solution doesn't it?
First of all I want to say that I set JavaScript and CSS files in "Razor" style. For instance:

Wednesday, June 13, 2012

Route of executing in Controller of ASP.NET MVC

Base classes of controller is ASP.NET MVC have number of methods for initialization before your code runs in an action. Lets review them.

  • First of all about constructor. You can't do a lot in it because most of properties aren't initialized yet and you will get NullReferenceException if try to use them.
  • Execute is inherited from IController interface and manages all other initialization methods. Usually you have to avoid override it.
  • Initialize sets ControllerContext. You should to override it if you need to set culture so on.
  • ExecuteCore is called to process request and responsible for loading TempData.
  • If I want to predefine some information (grab data from Session and so on) You should use OnActionExecuting. This methods is called just before executing your action method.
  • And finally you should use OnActionExecuted for any finalization after executing your code. 

PS: During preparing for this post I've used ILSpy. It is excellent free substitute for .NET Reflector (it is payment tool now).