Filtered by Tag (tips)
Have you ever used 'MSDeploy' inside Visual Studio 2010 and wished a nice process bar while publishing a web application? There is even a better way!
@ 03-05-2011
by Tugberk Ugurlu


image

Deployment of your web application is not hard anymore. It is so much easier than before with 'MSDeploy'. MSDeploy was introduced to us with Visual Studio 2010. It takes all the application and publish it how we want.

I am not going to explain what MsDeploy is and how it works. This is bot the topic here. I assumed that you are reading this post because you have had a least one or two experience with MSDeploy inside Visual Studio 2010.

When we are publishing an application with one click publish button, you probably noticed a little green world icon with coming and going tiny things on the left bottom side. That think is showing the process of your publishing but not so much informative. I thought that would be cool to view the remaining time of the process but Visual Studio has a lot better feature which I didn’t know until last night! Indeed, we have a chance to view the process file by file from output window of visual studio 2010 while publishing your application. That is pretty darn cool. But how we can configure this feature so that we could be able to view that.

imageWe need to go over to Tools > Options. Then expend the Projects and Solution section from the list on the window. You will find Build and Run section under that which will give you a window which will look like as it is here on the left. You notice that there is an option called 'MsBuild project build output verbosity'. There are five options there and it is set to Minimal by default. I changed it to Normal which is enough for our purpose here.

Save your settings and then expend the output window. You can start your publishing process now and you will see which file is now being deployed by MSDeploy as you can also see on the above screenshot. Yes, awesome… Smile Now, think about twice before using an FTP client again Smile

Solution to an annoying error message! You are getting 'Could not write to output file 'c:\Windows\Microsoft.NET\Framework\....' message? You are at the right place.
@ 03-05-2011
by Tugberk Ugurlu


This week I went nuts over my local IIS. I have never swore to a machine that much in my whole life. I am sure of that! The problem is not that big and probably not worth to be written on a blog post I am going to write it anyway because the solution was hard to find on the internet. Maybe this post will help you to fix the problem as I did and you will stop swearing to you machine as I did Smile

Let’s get to the point. I am no IIS guy! Seriously!  The so called Cassini (the tiny web server which pops up when you run a web application on Visual Studio) was so enough for me for over 2 years. But no more enough. I figured that IIS can not be ignored by me anymore. How can I get that point? That’s not the issue here. The issue is that I tried to run an ASP.NET MVC 3.0 application under my local IIS 7.0 and got a very annoying error. Which is;

Compiler Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\62d43c41\27d749ca\App_Code.7lodcznm.dll' – 'Access denied.'

imageTemporary ASP.NET Files folder (c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files) was the the one with the problem here. First, I thought that the problem is related to security permissions on the folder and I was right.

I right clicked on the Temporary ASP.NET Files folder and go to the security tab. I noticed that there is user called IIS_IUSRS and that guy has the full control permission. But apparently that was not enough.

The Temporary ASP.NET Files  and C:\Windows\temp folders should have IIS_WPG and NETWORK SERVICE users with the full control permission. I have no idea why C:\Windows\temp folder needs that but I have no effort left to try to find that. Instead, I am writing a blog post about the problem. Maybe latter I will get to that and figure it out, too Smile

Once you applied those setting, restart your IIS and try to run your application again. The error should be gone by now.

I suffered a lot by trying to find the right method for the problem and I hope you didn’t have to go through hell over this.

Hope this helps Smile

This post is a quick demonstration of how you can throw HttpException of 404 manually from a controller on ASP.NET MVC when the model you're passing is null
@ 02-17-2011
by Tugberk Ugurlu


How do you handle your actions inside a controller when the model you are passing to the view is null? Sometimes it is best to show ‘There is no product as you requested’ kind of message but sometime it is getting dull. Especially on CRUD based actions.

HttpException is becoming very handy here. We could throw this exception from our controllers and the application will render the status exception page we are defining. In this post I would like to show how we handle this properly. Here is our scenario : we have an MVC app and in one of our edit page, we would like to throw 404 exception if the model we are passing is null.

 

        [Authorize]
        public ActionResult Edit(Guid id) {

            var model = Repository.GetSingle(id);

            if (model == null)
                throw new HttpException(404, "not found");

            return View(model);
        }

 

This code is basically telling that try to get the item whose ID is id and check if it is null. If it is null, throw HttpException whose status code is 404. If not, return the View along with passing model into view page.

When we hit a page which has null model, we will see the 404 page as expected;

image

This is that easy ! Give it a try, it won’t hurt Smile

Sometimes we get sick to put our avatar pic. to every web site that we have registered to view our avatar. In this point gravatar.com helps us.
@ 11-19-2010
by Tugberk Ugurlu


Sometimes we get sick to put our avatar pic. to every web site that we have registered to view our avatar. In this point gravatar.com helps us. 

Gravatar works very basicly and securely. Firstly, you need to go to gravatar.com and sing up. After uploading your avatar and configure it with your e-mail address, your are basically done.

When you are writing a comment to a blog post, you are mostly required to enter your e-mail address and that e-mail address is enough to put your global avatar along with your comment. Of course, this is valid if the web site accepts gravatar pictures. 

Do not panic whether your e-mail address will be on picture's url. It won't. The picture url will similarly looks like that;

http://www.gravatar.com/avatar.php?gravatar_id=17698e3ad0e0dc70853cddda166bc573&size=80&default=identicon

You could easlily take advantages of gravatar and use it on your website. You could read implementation guidance for more information.

If you are using ASP.Net MVC and you are familiar with NuGet, the implementation will be so easy.

Implementation of Gravatar on ASP.Net MVC

  1. Write this command on Package Management Console : PM> install-package Microsoft.MVC.Helpers
  2. After the instalation, you will see Microsoft.MVC.Helpers.Gravatar.GetHTML(...) method. That method will generate the gravatar automatically.

Hope this helps !



Hi 🙋🏻‍♂️ I'm Tugberk Ugurlu.
Coder 👨🏻‍💻, Speaker 🗣, Author 📚, Microsoft MVP 🕸, Blogger 💻, Software Engineering at Deliveroo 🍕🍜🌯, F1 fan 🏎🚀, Loves travelling 🛫🛬
Lives in Cambridge, UK 🏡