In my ASP.NET MVC 3 web application, I use many partial views. I use these partial views in some cases through regular rendering calls
<div id="attributes"> @Html.Partial("_DeviceAttributesPartial", Model.DeviceAttributes) </div>
and in other cases using AJAX:
$.ajax({ url: '@Url.Action("GetDeviceAttributes")', type: 'POST', data: { deviceID: device, deviceTypeID: devicetype, deviceModelID: devicemodel }, success: function (result) {
I tried to find a way to prevent users from navigating directly to my partial ActionResults view, for example:
public ActionResult GetDeviceModelList(int deviceTypeID) { var model = new EditDeviceViewModel(); var deviceType = _db.DeviceTypes.Single(t => t.ID == deviceTypeID); model.DeviceModelList = new SelectList(_db.DeviceModels.Where(m => m.DeviceType.ID == deviceType.ID), "ID", "Model"); return PartialView("_DeviceModelListPartial", model); }
I came across this answer just to make the action private . I tried and it seemed to work, but I was embarrassed to do this without knowing what other side effects might occur.
So my questions are:
- Is setting up
private actions reasonable? - What other side effects may result from this?
- How about actions available only through
POST ?
NB: Most of the functions of the partial action result [HttpPost] , so I do not believe that they are available in any case.
source share