Search

Categories

Send mail to the author(s) E-mail

# Tuesday, July 06, 2010
( ASP.NET MVC | Moq )

While using Moq to test an MVC app, and Scott Hanselman’s NerdDinner app, I kept getting these strange errors.

Problem was permissions on:

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

In Windows XP Pro, you need to disable simple file sharing.. from http://www.windowsbbs.com/windows-xp/52502-cannot-change-permissions-folder.html

image

Then I set perms to be full control to everyone:

image

More granular perms are in here: http://groups.google.co.uk/group/RhinoMocks/browse_thread/thread/26df68ff01567509/5ddebf407228edc4

Now this code works:

image

On Win7: C:\Users\All Users\Microsoft\Crypto\RSA\MachineKeys

Takes some messing around with granting ownership of the directory, then setting full control to everyone.

Comments [0] | | # 
# Friday, July 02, 2010

Useful if you want the ASPNETDB to be in your local SQL Server instance rather than a flat file (which can be troublesome).

image

Use trick of connection via server explorer, then F4 properties, then can copy and paste connection string into web.config.

image

Comments [0] | | # 
# Tuesday, June 29, 2010

see about half way down this article for the first working MVC1 app connecting to the db.

http://wag.codeplex.com/

Using the EntLib5

image

Music Store App (Mar 23rd)

image

Hello World sample bits of code from MS:

image

 

Transferring data up to SQL Azure.. using Script Manager in SQL Man Studio 2008..

http://www.msteched.com/2010/NorthAmerica/COS311

 

Doing a Simple MVC Application and Publishing up to the Cloud (no DB)

This is a simple new project, Cloud Service, ASP.NET MVC2 Web Role

Right click on the VoucherMVC project, then publish.  Upload via the Web Interface.

image

NerdDinner

http://www.marcmywords.org/post/NerdDinner-hosted-on-Windows-Azure-and-SQL-Azure.aspx

Failed to generate a user instance due to a failure in starting the process… DB Error:  Solved by deleting a directory on my local machine (Win 7).

http://www.aspdotnetfaq.com/Faq/fix-error-Failed-to-generate-a-user-instance-of-SQL-Server-due-to-a-failure-in-starting-the-process-for-the-user-instance.aspx

 

Populating the Database

http://azurefeeds.com/post/923/Migrating_an_Existing_ASP.NET_App_to_run_on_Windows_Azure.aspx

Showing how to export a SQL script into SQL Azure format:

image

Ok, have got nerddinner database up there. 

ASP.NET Membership Provider..

http://blogs.msdn.com/b/jnak/archive/2009/11/24/asp-net-provider-scripts-for-sql-azure.aspx

http://www.marcmywords.org/post/NerdDinner-hosted-on-Windows-Azure-and-SQL-Azure.aspx

Details how to get the asp.net membership provider scripts working, using modified scripts.

http://support.microsoft.com/kb/2006191/en-gb

 

Issue with NerdDinner MVC2

Came across realm issue with regard to OpenID code, so reverted back to MVC1 code.

NerdDinner MVC1 Migrate to Azure – This Worked

Get it working normally in MVC (with 2 databases running SQLExpress in AppData folder)

Getting the Phone# does not match country error in nerddinner.

hacked the Helper/PhoneValidator.cs to always return true.

image

Deleted the unit test project for simplicity

Added a CloudService project into the solution

Right clicked on Role in CloudService, and added in the existing NerdDinner project

Added back in ConnectionStrings.config into the NerdDinner project

image

Coppied the database to SQL Azure using Management Studio 2008R2

Coppied Membership Provider to SQL Azure using special sql scripts

Added in ConnectionStrings.config into the project, and put in SQL Azure string.

Uploaded to Azure..

**problem goes between stopping and initializing… after 20mins?

Try recreating Service in Asia, and DB is in Asia too.

Try uploading again.. and putting one in staging too ( a simple MVC no database, includes test project, worked before).  9:50pm started.

image

App does work from local using SQL Azure as storage..

image

After sleeping on it, the problem was that copy local wasn’t set to true on the System.Web.Mvc reference.

image

Comments [0] | | # 
# Wednesday, June 23, 2010

While trying to figure out what is meant by the 3rd new section in a view in MVC

<%: Html.ActionLink("Edit", "Edit", new { id=item.DinnerID }) %>

So it is really creating an object with a single property id, which is an int, equal to that of the item, which is a Dinner.

image

“Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to first explicitly define a type”

class Program
{
static void Main(string[] args)
{
// Anonymous types provide a convenient way to encapsulate a set of read-only properties
// into a single object without having to first explicitly define a type
var person = new { Name = "Terry", Age = 21 };
Console.WriteLine("name is " + person.Name);
Console.WriteLine("age is " + person.Age.ToString());

// Anonymous types just get rid of Person1 really.
Person1 person1 = new Person1 { Name = "Bill", Age = 55 };
Console.WriteLine("name is " + person1.Name);
Console.WriteLine("age is " + person1.Age.ToString());
}
}

class Person1
{
public string Name { get; set; }
public int Age { get; set; }
}

Many thanks to the question here for clarifying:
 
Comments [0] | | # 
# Tuesday, June 22, 2010
( Azure )

In the 1.2 Release of the SDK we can now publish straight from VS instead of manually uploading files.

The end results is this:

image

which automatically publishes up to the cloud and runs the app making it live.

The way to do it is to select manage in Credentials, which brings up this box:

image

1. Create a self signed cert. 

2. upload it to the dev portal

3 grab your subscriptionid from Account page

You’ll need a storage account to setup through as well.

Comments [0] | | # 
# Thursday, May 27, 2010

DevDays – MVC – Scott Hanselman video:

WFT1_2MB_ch9.wmv 1.4GB

Looking at the callstack in debug to see how things are called.

image

IHttpHandler – the ‘simple’ building block of ASP.NET.

Example in c:\code\mvc2\hanselman

image

http://localhost:1476/Home/poop/2

Controller get invoked

Action invoker calls the method

Model Binding – took the other piece of the route data (ie 2) and coerced it into…

didn’t call HttpRequest or anything..

 

Passing a DateTime

image

image

Phil Haack Route Debugger

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

 

image

prop tab tab to auto gen the properties. then tab tab, then enter enter!

Create A Controller

Ctrl M, Ctrl C

Convention is HomeController

var p = new person

then ctrl period to import the namespace.

Create A View

Convention is in Views directory, create a new Person directory.

Index method links to Index view

Details method links to details view.

image

image

Ctrl M Ctrl V to create a view, when you are in the appropriate Controller class (eg Index)

Created a strongly typed view.. this Viewpage is of type Person

Model in the viewpage will always be of type T ie Person.

Could use Repository Pattern for the DB

Going live with ASP.NET4 – many hosting providers need you to upgrade to another machine.

image

Going Live on Azure

Created a new MVC2 Web Role project

Upload to test that MVC2 is working somewhat

ViewModel - MVCMusicStore

VS2010 Control comma – navigate to

http://mvcmusicstore.codeplex.com/

Uses Entity Framework.

Uses <%: HTml.DisplayForModel

AutoMapper

FirstName, LastName.. map to FirstName and Surname

image

ViewData

is another way to pass data.

image

ViewEngines

This is the WebForms view engine.

Routing

 

NerdDinner – MVC2 in beta (now it is live 27th May)

there are unit test in here.

image

just asserting not null.

Seperation of Concerns – in controller we can’t have Response.Write.. as it would break in this test.  Would work at runtime.

Comments [0] | | # 
( Azure )

Personal storage

Endpoints:

xxxxx.blob.core.windows.net

xxxx,queue.core.windows.net

xxxx.table.core.windows.net

This part of Windows Azure and not SQLAzure or AppFabric

image

azurestorageexplorer.codeplex.com

image

Also looking at Azure Diagnostics Manager from cerebrate.com

http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/e972b0c0-3a04-4f0c-a73f-ab93552d8291

Example using ASP.NET and Storage and AppFabric Local Dev

http://msdn.microsoft.com/en-us/magazine/ee336122.aspx

Logging

Each app has to do its own logging and write to storage.. an app like this can nicely show what is happening.

image

http://microsoftpdc.com/sessions/svc15 –  this is pdc09

MIX2010 – Building and Deploying Windows Asure Based Apps

http://live.visitmix.com/MIX10/Sessions/SVC09  (Jim Nakashima)

Created a WebRole and a WorkerRole

image

One of the web roles.. when I clicked on the button, the worker role picked up the message from the queue.

Nerdinner MVC1 Migrating to Azure with SQLAzure

Could use Azure tables (examples on the web)

Need to do 3 things:

- Need to make a webrole

- Migrate dinner to use SQLAzure

- Migrate asp.net membership provider for SQLAzure.

Comments [0] | | # 
( SQLServer | VMWare )

 

using the Web Plaform Installer. installation of the Studio didn’t work

tried ccleaner which didn’t work.

http://goneale.com/2009/05/24/cant-install-microsoft-sql-server-2008-management-studio-express/

Trick is to get the DB Server and tools together: **No this is just SQL Server 2008, not R2**

https://www.microsoft.com/downloads/details.aspx?familyid=7522A683-4CB2-454E-B908-E805E9BD4E28&displaylang=en

But as I’d compressed my C:\ drive on WMWare Player it came up with an unusual error.

This is good:

image

image

Expand Boot Drive on VMWare Player3

Need VMWare Player 3.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1004047

Can simply edit the drive information in the player GUI, then goto Windows7 click on C:\ drive in admin tools and management, and then do expand volume.

Comments [0] | | # 
# Wednesday, May 26, 2010
( Azure )

http://blogs.msdn.com/b/brandonwerner/archive/2009/11/28/how-to-host-your-site-and-content-on-azure-quickly-and-easily.aspx

Local Development Fabric and Development Storage (uses SQLEXPRESS)

image

Live ‘Fabric’ and Storage which consists of Blob, Queue and Table

image

SQLAzure is something else!

AppFabric is something else.

Comments [0] | | #