Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Thursday, 3 May 2012

ASP.NET MVC login page throwing error "The resource cannot be found"


As per ASP.NET MVC getting the error message "The resource cannot be found" is as simple as verifying if the view/user control does actually exist or name of the view/user control is misspelled.

But in this case that is not the issue because the controller "AccountController" does exist and the view "Login.aspx" also does exist. So have started using google search and tried various suggestions but nothing did work.

Also I have created another sample ASP.NET MVC standard project and have modified web.config to use forms authentication and that works, so the issue is not the environment.

Actually I have missed out a point about some configuration changes I have made to project. The requirement was actually to support "IIS 7" & "IIS 6" as well. The changes I have actually made are

1. Added extra routing in global.asax.cs
public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default.aspx", // Route name
                "{controller}.aspx/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Default", id = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "Root",
                "",
                new { controller = "Home", action = "Default", id = UrlParameter.Optional });
        }
2. Added "default.aspx" to project at the root
3. Now add "Page_Load" event to code behind
public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.RewritePath(Request.ApplicationPath);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current); 
        }
    }

All these changes allows running ASP.NET MVC application on IIS6. All this said I am still unable to find out the fix for this issue. Started looking at the error message again to see if I have missed out any thing, Aha.... I found it. Look at the url on the address bar
http://localhost:49668/Account/Logon?ReturnUrl=%2fdefault.aspx

Lets look at first route map
 routes.MapRoute(
                "Default.aspx", // Route name
                "{controller}.aspx/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Default", id = UrlParameter.Optional } // Parameter defaults
            );

ie.. request for "default.aspx" will use "Home" controller with action as "Default"

Second route map
 routes.MapRoute(
                "Root",
                "",
                new { controller = "Home", action = "Default", id = UrlParameter.Optional });

ie.. request to root of the website to be redirected to "default.aspx", use "Home" controller with action as "Default"

Both are fine but I have missed out default ASP.NET MVC routing which is (ie.. "{controller}.aspx" modified to "{controller}"
 routes.MapRoute(
                "Default", // Route name
               "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Default", id = UrlParameter.Optional } // Parameter defaults
            );

After adding this application started working and I have got the login page.

Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
~Clifford Stoll

Tuesday, 1 May 2012

Unable to debug Visual Studio 2010 addin or suddenly stopped working

I have created a new addin for Visual Studio 2010 using standard addin template. The sample works fine, then I start making some changes and adding more dependencies. Yes got some compilation errors and have fixed them. Now after starting debugging a runtime error is thrown, so fixed that.

Now If I start debugging, the addin no longer gets loaded and also won't show in Addin Manager (VS2010 -> Tools -> Add-in Manager). Now this is really getting me upset.

Used our friend google to find a solution but no luck. So started looking at places where addins were loaded from, aha.. I found the issue.



1. Looking at "C:\Users\Saif\Documents\Visual Studio 2010\Addins" I have found the addin file was renamed from "MyAddin2 - For Testing.AddIn" to "MyAddin2 - For Testing.AddIn_" ie.. an "_" in the end. I think this might have done by visual studio, ie.. since visual studio is unable to load the addin it has renamed by adding "_"

So renaming back from "MyAddin2 - For Testing.AddIn_" to "MyAddin2 - For Testing.AddIn" started loading the addin.

2. Also verify Project Properties -> Debug



1. "Start external program" : "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"
2. "Command line arguments" : "/resetaddin MyAddin2.Connect"
3. "Working directory" : "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"

The inside of a computer is as dumb as hell but it goes like mad! ~Richard Feynman

Sunday, 29 April 2012

Storing TFS Credentials in VS2010

Visual Studio 2010 have not got an option to store credentials of TFS login which make you really cranky at times. So to store the credentials and avoid the prompt when connecting to external TFS server please follow the steps below:-

Using windows 7

1. Go to Control Panel -> User Accounts and Family Safety -> User Accounts
2. Select "Manage your credentials"
3. Select "Add a Windows credential"
4. Specify the network address (for eg:- tfs.codeplex.com)
5. Now provide username and password, select "Ok" to save your credentials.

Now when you try to connect to external TFS servers you will not see login prompt, but remember to update your password if its changed.

There are three kinds of death in this world. There's heart death, there's brain death, and there's being off the network. ~Guy Almes

Thursday, 26 April 2012

Setting up FileZilla Server and Client for transferring files with FTP

FileZilla is a free FTP solution that allows you to setup an FTP site with in minutes. Refer to filezilla site for more details

Setting up the FileZilla Server


Installing FileZilla Server


1. Goto FileZilla Server and download the "FileZilla_Server-0_9_41.exe"
2. Run "FileZilla_Server-0_9_41.exe" and select Next
3. Choose components to install
4. Choose Install location (use default location)
5. Select service start-up settings
6. Select FileZilla interface start-up settings
This should complete the installation


Configuring FileZilla Server


Configure Group


1. Start FileZilla service (Start -> All Programs -> FileZilla Server -> Start FileZilla Server)
2. Now open FileZilla Interface (Start -> All Programs -> FileZilla Server -> FileZilla Server Interface)
3. Use default settings on the connect to server dialog
4. Connection should succeed and display FileZilla Interface
5. Select Edit -> Groups
6. Select "Add" and specify group name
7. Now select "Shared folders" and add a directory (eg: D:\MyFTPShare\csharptechies)


Configure Users

8. Select Edit -> Users and add a user account
9. Select "Password" and assign a password 10. Select "Shared folders" and add a directory (eg: D:\MyFTPShare\csharptechies)
Note: Assuming this is admin account assign all permissions for the directory 11. Add another user (like a friend or colleague who belong to same group)
12. Select "Password" and assign a password 13. Select "Shared folders" and add a directory (eg: D:\MyFTPShare\csharptechies\saif)
Note : Instead of giving permissions for the directory that belongs to the admin, create a sub directory under that for each user. Repeat steps 11,12 & 13 for all users in the group.

Installing FileZilla Client


1. Goto FileZilla Client and download the "FileZilla_3.5.3_win32-setup.exe"
2. Run "FileZilla_3.5.3_win32-setup.exe" and select Next
3. Choose components to install
4. Run to completion

Connecting FileZilla Client to Server


1. Open FileZilla Client (Start -> All Programs -> FileZilla FTP Client -> FileZilla)
2. select File -> Site Manager
3. select "New Site" and specify details (port number is not required if firewall is not enabled)
4. Now select "connect"
Now looking at FileZilla Server interface will show the list of users (clients) connected
All done !!!!. Now you can transfer (upload/download) files between server and your clients.

Other ways of connecting clients to FileZilla Server


- Open windows explorer and specify ftp location ftp://129.86.76.32/, then provide the user credentials
- Open firefox browser and provide the url as ftp://saif@129.86.76.32/ (needs firefox plugin fireftp)

“We have to stop optimizing for programmers and start optimizing for users.”
– Jeff Atwood

Sunday, 25 March 2012

Sharing photos using SignalR

SignalR is the latest .NET library available for broadcasting data from a hub to its clients (similar to polling methods used for various sites such as facebook, twitter etc). More information about SignalR is available at signalr.net

I have tried a simple mvc application that can be used to share photos between friends which gets updated instantaneously. An user connected to the website can upload a photo which will be automatically broadcasted to all clients connected at that point.

Here is how it looks:-



Latest version of source is available at photowebpro.codeplex.com

SignalR is an asynchronous signaling library for ASP.NET that can be used to build real-time multi-user web application. There is a simple and interesting video available on Channel 9 about SignalR, which will give you a heads-up.

Technology presumes there's just one right way to do things and there never is. ~Robert M. Pirsig

Thursday, 8 March 2012

Using join on a subquery with NHibernate

NHibernate is one of the best ORM solution available. That said sometimes its not easy to find a way around your problem. I have been trying to create a join on a subquery and want to uses "EXISTS" on a table to be more efficient.

Here is my class design


All I want is to get list of flytoys for a purchase order
- filter on customer name
- get the oldest purchase order

After trying many various methods, here is the code snippet that worked for me:

  public FlyToy[] GetPendingToys(int Count)
        {
            using (var session = OpenSession())
            {
                PurchaseOrder po = null;
                FlyToy toy = null;
                QueryOver subQuery = 
                    QueryOver.Of(() => po)
                        .SelectList(list => list
                            .SelectGroup(() => po.Toy.ID)
                            .SelectMin(() => po.OrderDate))
                        .Where(Restrictions.EqProperty(
                            Projections.Property(() => po.Toy.ID),
                            Projections.Property(() => toy.ID)))
                        .Where(p => p.CustomerName == "Saif");


                var mainQuery = QueryOver.Of(() => toy)
                    .Fetch(t => t.Discount).Eager
                    .WithSubquery.WhereExists(subQuery).Take(Count);

                IList results = mainQuery.GetExecutableQueryOver(session)
                    .List();

                FlyToy[] FlyToys = results.ToArray();
                return FlyToys;
            }
        }


Be nice to nerds. Chances are you'll end up working for one.
- Charles Sykes

Friday, 2 March 2012

Website giving an error Retrieving the COM class factory for remote component with CLSID

I have got a website which was working fine until today and all of sudden I am getting following error message when tried to access the website.

Retrieving the COM class factory for remote component with CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} from machine MMMMMMMM failed due to the following error: 80070005.

There's has been no changes to the code base,no changes to its dependencies and nothing noticeable. So remember the word noticeable, simple to say but very hard to point out. The error code 80070005 usually means that you do not have enough permission.

That does not help at all why would I get an error message as not enough permission if I am using windows authentication for the website. After digging some more the situation is this website is making a call to another webservice which is giving this error message.

Fine now both of them are running under the same application pool then it should work, but its not. Finally working through all the odd methods I have found impersonation is set to true for the website that's hosting the web service. I have just made

impersonate=false 

and yes that started working.

All in all the point I have missed out in my investigation is checking web.config. Anyway lesson learned for next time.

Information technology and business are becoming inextricably interwoven. I don't think anybody can talk meaningfully about one without the talking about the other. ~Bill Gates
Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers