Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had to do something very similar, and I used the nvelocity view engine from <a href="http://www.codeplex.com/MVCContrib" rel="nofollow noreferrer">MVCContrib</a> - technically you could use the default aspx view engine, but I found that the nvelocity syntax was a lot more straightforward for puting out script (don't worry if you haven't used it before - I spent about 10 minutes figuring it out!).</p> <p>Then you just need to add a route to the route table to handle directing your .js url to the action!</p> <p><strong>EDIT</strong></p> <p>Can't verify this as I don't have visual studio to hand but for the route, you might have something like this:</p> <pre><code>RouteTable.Routes.Add(new Route { Url = "[controller]/[action].js", Defaults = new { controller="home", requestType="javascript" }, // Whatever... RouteHandler = typeof(MvcRouteHandler) }); RouteTable.Routes.Add(new Route { Url = "[controller]/[action]", Defaults = new { controller="home"}, // Whatever... RouteHandler = typeof(MvcRouteHandler) }); </code></pre> <p>Requests ending in .js should go through the first route - extensionless requests fall through to the second.</p> <p>Then your action could have a requestType param:</p> <pre><code>public ActionResult MyAction (RequestType requestType) { if(requestType == RequestType.JavaScript) { ... new nvelocity view to render javascript } else { ... } } </code></pre> <p>As for directory structure - you're on your own with that! Not because I don't want to be helpful, but more down to the fact that you have flexibility to do what you want with it!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload