Collection Form Post Parameters in WebAPI Controller

image.png

There are lots of ways using ASP.NET MVC4 to collection passed in form parameters (POST) to the WebAPI Controller.  I’m not wanting to create a Model, I’m not wanting to get involved with dynamic variables, I just want the values that are posted in.  Say for example, my post looks like the following: To capture both sessionId and trackId, I can have a WebAPI controller in Visual Studio that looks just like this: namespace WebAPI.Api{ public class SessionRpcController : ApiController { [HttpPost] [ActionName("UpdateSessionTrack")] [Authorize(Roles = "admin")] public HttpResponseMessage PostUpdateSessionTrack( FormDataCollection formDataCollection) … Continue Reading

Simple DropDownList With Default Value Using ASP.NET MVC4, Razor and an HtmlHelper

image.png

First, the results of what you get.  Notice the URL parameter, the default value in the DropDownList and also the text value output on the page.   Visual Studio Project Project.zip Background I know a lot of us are struggling changing from ASP.NET WebForms to MVC4.  For me in particular, it’s been a struggle but I’m slowly seeing light at the end of the tunnel.  Our Silicon Valley Code Camp has been in the process of rewriting in MVC4 for the past many months, and with the help of contractors (and me), we are getting there.  Basically, the site has gone from: to The example I’m showing here is really based on just implementing a tag cloud manager. You can see an example of this in production and in … Continue Reading

Using Visual Studio 2012 Web Publish For Staging On The Internet

image.png

  Let’s say you have a production code like http://siliconvalley-codecamp.com and you want to have a test site on the internet that will not be seen by anyone unless they login (or maybe even login as an admin).  Using web.config (with Visual Studio 2012), transformations makes that very straight forward.  I know because I just did that.  I created a test site (say: http://test.siliconvalley-codecamp.com) and set up my publish to replace my normal anonymous authentication (allowing anonymous users) to one that denies anonymous users.  Just as an aside, the reason I did this was I notice that google was indexing some of those pages even though my robots.txt file says to deny access to all robots.  Apparently … Continue Reading

VS2012 Web Deploy, Using Transforms For Connection String In Production (Web.Config)

image.png

  Introduction I should have learned this a long time ago.  I certainly have known about it since VS2010 when it was introduced, I’ve read about it multiple times, I just thought I did not have the time to learn it so for the past couple years, I’ve been making one web.config change after another and of course making all the stupid little mistakes we all make (I think) when we do things manually. So, in 25 minutes this morning, I updated my http://siliconvalley-codecamp.com site with Web.Config transforms so now, when I “publish” with Visual Studio 2012 I just pick the correct profile (either beta4 or svccprod) and when I do the publish command, I get the correct database connection strings.  svcodecamptest for beta4 and … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: