title: ASP .NET MVC Form fields Validation (without model)
body: <p>I am looking for a way to validate two fields on ASP View page. I am aware that usual way of validating form fields is to have some <code>@model ViewModel</code> object included on a page, where the properties of this model object would be annotated with proper annotations needed for validation. For example, annotations can be like this:</p>
  
  <pre><code>[Required(ErrorMessage = "Please add the message")]
  [Display(Name = "Message")]
  </code></pre>
  
  <p>But, in my case, there is no model included on a page, and controller action that is being called from the form receives plane strings as method arguments.
  This is form code:</p>
  
  <pre><code>@using (Html.BeginForm("InsertRssFeed", "Rss", FormMethod.Post, new { @id = "insertForm", @name = "insertForm" }))
  {
  &lt;!-- inside this div goes entire form for adding rssFeed, or for editing it --&gt;
      ...
              &lt;div class="form-group"&gt;
                  &lt;label class="col-sm-2 control-label"&gt; Name:&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                      &lt;div class="controls"&gt;
                          @Html.Editor("Name", new { htmlAttributes = new { @class = "form-control", @id = "add_rssFeed_name" } })
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-sm-2 control-label"&gt; URL:&lt;/label&gt;
                      &lt;div class="col-sm-10"&gt;
                          &lt;div class="controls"&gt;
                              @Html.Editor("Url", new { htmlAttributes = new { @class = "form-control", @id = "add_rssFeed_Url" } })
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
              &lt;!-- ok and cancel buttons. they use two css classes.  button-styleCancel is grey button and button-styleOK is normal orange button --&gt;
          &lt;div class="modal-footer"&gt;
              &lt;button type="button" class="button-styleCancel" data-dismiss="modal"&gt;Close&lt;/button&gt;
              &lt;button type="submit" class="button-styleOK" id="submitRssFeed"&gt;Save RSS Feed&lt;/button&gt;
          &lt;/div&gt;
  }
  </code></pre>
  
  <p>You can see that form is sending two text fields (Name and Url) to the RssController action method, that accepts these two string parameters:</p>
  
  <pre><code>[HttpPost]
  public ActionResult InsertRssFeed(string Name, string Url)
  {
  
      if (!String.IsNullOrEmpty(Name.Trim()) &amp; !String.IsNullOrEmpty(Url.Trim()))
      {
          var rssFeed = new RssFeed();
          rssFeed.Name = Name;
          rssFeed.Url = Url;
  
          using (AuthenticationManager authenticationManager = new AuthenticationManager(User))
          {
              string userSid = authenticationManager.GetUserClaim(SystemClaims.ClaimTypes.PrimarySid);
              string userUPN = authenticationManager.GetUserClaim(SystemClaims.ClaimTypes.Upn);
  
              rssFeedService.CreateRssFeed(rssFeed);
          }
      }
  
      return RedirectToAction("ReadAllRssFeeds", "Rss");
  }
  </code></pre>
  
  <p>If the page would have model, validation would be done with <code>@Html.ValidationSummary</code> method, but as I said I am not using modelview object on a page. 
  Is there a way to achieve this kind of validation without using ModelView object, and how to do that? Thanks.</p>