我有一个例外由另一个代码的直接副本引起:
控制器:
public PartialViewResult Pictures()
{
picturesList.Clear();
CloudTable table = _Service.GetCloudTable();
CloudBlobContainer blob = _Service.GetCloudBlobContainer();
TableQuery<PictureEntity> query = new TableQuery<PictureEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "hiltihaningepictures"));
foreach (PictureEntity pic in table.ExecuteQuery(query))
{
picturesList.Add(pic);
}
picturesList.Sort();
return PartialView();
}
查看:
@model List<WebRole.Models.PictureEntity>
<script type="text/javascript" src="~/Scripts/jquery.liquid-slider.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.touchSwipe.min.js"></script>
<script type="text/javascript">
$(function () {
$('#main-slider').liquidSlider({
height: '525px',
minHeight: '525px',
dynamicArrows: true,
dynamicArrowsGraphical: true,
autoHeight: false,
continuous: true,
autoSlide: true,
pauseOnHover: true
});
});
/* If you need to access the internal property or methods, use this:
var api = $.data( $('#slider-id')[0], 'liquidSlider');
*/
</script>
<div id="main_liquid" style="display: none;">
@foreach (var item in Model)
{
<div class="liquid-slider" id="main-slider">
<div>
<img src="@item.Url" class="intro_img_group" />
<p>Uppladdad av: @item.Uploader, @item.Timestamp.DateTime</p>
<p>Beskrivning: @item.Description</p>
</div>
</div>
}
唯一的区别是,另一个工作得很好且花花公子的视图不包含Javascript部分。除此之外完全相同。
异常详情:
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=App_Web_v2igssw5
StackTrace:
at ASP._Page_Views_Home_Pictures_cshtml.Execute() in g:\HiltiHaninge\HiltiHaninge\Views\Home\Pictures.cshtml:line 23
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
它建议我使用关键字new,但我不知道该怎么做