title: How to get only the Controller name and action name from URL with jQuery
body: <p>I am using .net MVC in my website and I need to get the URL in javascript, but only the controller and action name, for instance if i have:</p>
  
  <p><code>http://stackoverflow.com/questions/9513736/current-url-without-parameters-hash-https</code></p>
  
  <p>I need:</p>
  
  <p><code>http://stackoverflow.com/questions/9513736/</code></p>
  
  <p>I have found some solutions such as:</p>
  
  <p><code>urlBase = location.href.substring(0, location.href.lastIndexOf("/")+1)</code></p>
  
  <p><code>-&gt;http://stackoverflow.com/questions/9513736/</code></p>
  
  <p>However if my URL does not have any parameters I the action name is cut off like so:</p>
  
  <p><code>http://stackoverflow.com/questions/</code></p>
  
  <p>Does anyone have a solution for this?</p>