The ActionName attribute is very powerful in Sitefinity

Friday, October 3, 2014 0 comments

If you haven’t heard, Sitefinity allows for not only ASP.NET WebForms development but also ASP.NET MVC development.  http://www.sitefinity.com/mvc-cms There are different modes to MVC development in Sitefinity: Classic, Pure, and Hybrid.  I think the most common would be hybrid.  If you have an existing site and add a new MVC widget, you’re probably going to use Hybrid.

Code in Hybrid mode is a mix of WebForms in your MasterPages and Razor ASP.NET MVC in your widgets.  The routes in Hybrid mode are mixed also.  I mean to say that the routes are built for WebForms to work first and MVC second. Because of this you need to pay attention to the ActionName attribute on your control ActionResults and also your form tags.

Your controller

   1: /// <summary>



   2: /// This is the success Action.



   3: /// </summary>



   4: [ActionName("Success")]



   5: public ActionResult Success()



   6: {



   7:     LoginModel model = new LoginModel();



   8:     return View(model);



   9: }



  10:  



  11: [HttpPost]



  12: [ActionName("Success")]



  13: public ActionResult Success(LoginModel model)



  14: {



  15:     if(ModelState.IsValid)



  16:     {



  17:  



  18:     }



  19:     return View(model);



  20: }




Note that we use the ActionName attribute “Success”.  Normally you don’t have to do this.  The ActionName is inferred from the method name.  In Sitefinity Hybrid mode this is not the case.



Your view





   1: @model SitefinityWebApp.Mvc.Models.LoginModel



   2: <h1>



   3:     @ViewData["HeaderText"]



   4: </h1>



   5: @using (Html.BeginFormSitefinity("Success", "<NAME OF WIDGET>", FormMethod.Post))



   6: {



   7:     



   8: }




In your MVC view, you’ll use the helper BeginFormSitefinity.  A good convention is to use the name of the widget as the form name and we need to use the ActionName attribute “Success” in this sample to match our controller.  Here we are posting a form with inputs.



I hope this explains the power of ActionName.  It is seldom used it normal MVC development but necessary to Sitefinity MVC development.

My New Home Away From Home

Monday, January 27, 2014 0 comments

For those of my readers that have missed me, I’m going to try to write more in 2014.  So for my first post of the new year, I want to talk about what I’ve been doing the last 6 months.  I’ve been onboarding as Director of Application Development at Foundation 648, Inc. F648 is a 4 year old .NET shop here in Indiana.  It was started by Patrick Poer and Buck Brian.  After meeting them we just hit it off.  I’m still learning about all they did in the past and we are expanding our capabilities rapidly.  It’s really challenging and I’m having a heck of a great time.

 

We recently moved into some permanent space with room to grow.  The new address is 11711 N. Pennsylvania St, Suite 255, Carmel, IN 46032.  We currently have space for 5 or 6 more developers and can easily expand down the hall.  It’s a great environment and we are hiring.

 

Here are some pictures of the my new home away from home.  I have a really nice office and all the bruises have healed from moving desks.  We work hard at F648 and love to do everything ourselves. 

 

Go thru the main entrance in the rear.  There is retail in the front and office space in the back of 11711.

 

WP_20140127_014

Take the elevator upstairs

 

WP_20140127_013

 

After you get to the 2nd floor turn right

 

WP_20140127_011

 

Suite Entry

 

WP_20140127_010

 

Reception Area

 

WP_20140127_009

 

Break room

 

WP_20140127_008

 

Developer Pit

 

WP_20140127_006

 

Hallway

 

WP_20140127_004

 

President’s Office with a door to the deck

 

WP_20140127_003

 

My Office, no door but a great view

 

WP_20140127_002

dotNetConf - .NET Open Source Panel

Thursday, June 13, 2013 0 comments
I'm just catching up on some videos that I promised myself to go back and watch.  This one is cool.  Great panel included OpenRasta and ServiceStack developers among others.



SQL Saturday #175 Fargo, ND April 27th

Friday, March 15, 2013 0 comments
SQL Saturday #175 Fargo, ND

When I heard SQL Saturday is coming to Fargo, ND on April 27th, 2013, I could't believe it. I was onsite at a client in Fargo when the news came out.  That was a sign, I must submit a session.  Fargo is growing rapidly, heck the whole state of North Dakota is.  Fargo getting a SQL Saturday is not surprising with the oil boom and the growth of the internet and the new technology in agriculture.  North Dakota has more data than ever.  Good thing I like data.

The title of my session is "A Complete BI Solution in About an Hour!"  I really appreciate the whole Microsoft SQL stack and how you can, with one install and some quick setup, really get a problem solved in no time at all.  I'll be re-working my slide deck a bit from previous events and have new code to show.  I might even throw in some nice HTML5, CSS, and JavaScript wiz bang to end the show.

As of right now, I'm on at 10 am in room 1. SCHEDULE HERE That's a really good time for me.  My session is the only beginner level talk in that 10am slot so I hope there will be enough beginners that want to hear about BI.  If I don't fill the room, I can take more questions and show all the other ways that Microsoft makes BI easy for us SQL developers to get the job done.  

See you in April! I hear there are a lot of registrations.  I'm not surprised it's only $10 for a full day of SQL goodness.
 
 

JavaScript should be your favorite language

Thursday, March 14, 2013 0 comments
So you think you're really cool because you're hardcore and know everything there is about PHP or C# or C++ or VB or Perl or Ruby or Python or ColdFusion or Java or ActionScript or..  I should stop right?  The thing is, as developers we've been coding in all these other languages to fit the phone, desktop, server and platform we think is best.  But we were wrong.  There is no "best" or "favorite" platform.  We shouldn't have been writing Flash apps.  We shouldn't have been writing Silverlight or Windows or Mono or XNA or Java apps.  We should have been writing HTML5 apps this whole time. 

Don't get me wrong.  I don't thing that the debate of standards based apps vs native apps is over.  I think it's going to go nuclear.  Soon their will be iOS, Windows, Ubuntu, Chrome, Android, Blackberry, Firefox OS, and more to come.  They (I assume) will all probably be a little different but there will be ways to write in just HTML5, JavaScript and CSS.

So if you are really cool and prefer all those other languages, maybe you should look at JavaScript a little closer like I have this past year.  Dive deep, don't just use it when you really have to.  Try out some server side stuff like Node.js.  Or, God forbid, write a Windows Store App in JavaScript instead of C#.  You might like it.  I do.

Brackets for Good

Monday, March 11, 2013 0 comments
Brackets for Good

This story actually starts for me back in 2010.  I volunteered for Indy GiveCamp.  My assignment was to help organize and lead a team to upgrade a community center's website to DotNetNuke.  That's when I was pulled in to help the Trusted Mentors team build a database application.  GiveCamps are really cool.  You get to code for charity, if you have the chance go volunteer.

Things circled back around in 2011 when I was developing some really cool medical device software at WoundVision.  We were doing really well at the time.  We had offices near Fountain Square where Trusted Mentors has it's office.  We got to sponsor a breakfast at the Fieldhouse event for them.  It happened to be my birthday, it was a really cool event and a great birthday present from WoundVision.  I miss all those poeple, we made some really good software together.

Now it's time for me to pay back so I've given a few bucks, that's all it takes. It's a really cool idea for March.  All non-profits benefit and there is a bonus at the end for the winning team.  Please help by going out to the Brackets for Good site and buying some points for your favorite team.  Perhaps that is even my favorite team, Trusted Mentors.


Poplulist vs Elitist

Wednesday, March 6, 2013 0 comments
I first need to tell you that is not a political blog. I don't have any agenda and seldom post anything too controversial. If you are looking for that sort of thing you'll not find it here. This post is about styles, techniques, or preferences in developing software.

I'm not an Elitist, at least I don't think I am. I'm very open minded and try not to force my views of engineering on anyone. I have been a team lead many times in the past though. I'm made decisions and dictated standards that might seem high and mighty. A lot of where I come from is Pragmatism. I don't like really over engineered 9 tier application frameworks. When I step through the debugger and hit the F10 key 50 times, I have a heart attack. Why all the nesting?

I'm not a Populist either. I don't necessarily think Ruby on Rails is the definition of MVC, even though most developers who do MVC use Rails. ASP.NET MVC is cool, as are others. I don't think that the iPhone and iPad are the best devices ever. I actually think they are a pain to use and too plain for me. I don't think that everyone should code the same way. Go4 can kiss my... I could really care less about how your css is minified as long as it works and doesn't take forever to download.

So why am I writing this blog post? I really don't like spaghetti code. I'm ok with 70% code coverage in NCover. If my app only has 3 layers, I'm ok with it. If I have to write a stored procedure to get what I want out of the database, cool. I can code from the UI in, or the schema out. What I don't like is over engineered bloat! I don't get along with Elitist software guys who care about REST vs RESTful.

My apps aren't for everyone and I didn't take a long time to code them. They are there for the users who like using them. My project plan was only 6 months long. We released on time, and hopefully we made money. My code doesn't have a lot of dependencies and is pretty simple, really fast. I'm not going to be an Elistist and tell you to follow my lead. But if my way becomes popular, I'm ok with that.

 
Copyright © Aaron Stanley King