asp.net mvc - DOT Exception When Trying To Open/Call a Funtion -


i have problem calling function show books same author, example have these authors :

author name : jeremy mcpeak; joe fawcett; nicholas c. zakas;

when click on "jeremy mcpeak" , "joe fawcett" new page opened , show books authors .

but when click on author "nicholas c. zakas" , since has dot in name , got exception

object reference not set instance of object.

this problem when click on author have dot in name ..

also here function :

public actionresult author(string authorname, int? page) {     if (authorname != null)     {         viewbag.authorname = authorname;         int pagesize = 6;         int pagenumber = page ?? 1;         var result = db.books.where(s => s.author_name.contains(authorname)).orderbydescending(x => x.book_id).tolist();         return view(result.topagedlist(pagenumber, pagesize));     }     return redirecttoaction("index", "home"); } 

author view code:

@using pagedlist.mvc @using system.text.regularexpressions; @model pagedlist.ipagedlist<smartbooklibrary.models.book> @{     viewbag.title = "books " + viewbag.authorname+ "- smart books library";     layout = "~/views/shared/_layout.cshtml"; } @section additionalmeta {     <meta name="robots" content="index,follow"> } <div class="container">     <!-- page header -->     <div class="row">         <div class="col-lg-12">             <h1 class="page-header">                                 <span class="fa fa-pencil"></span>@viewbag.authorname             </h1>         </div>     </div>     <!-- /.row -->     <!-- projects row -->     <div class="row">         @foreach (var item in model)         {             <div class="col-md-4 portfolio-item" style="margin-bottom:10px;height:450px">                 <div class="ih-item square effect3 bottom_to_top">                     <a href="~/book/@item.book_id/@item.urlslug">                         <div class="img"><img itemprop="image" class="img-responsive" src="~/images/@item.book_image" alt="@item.book_name" title="@item.book_name"></div>                         <div class="info">                             <h3>@item.book_name</h3>                         </div>                     </a>                 </div>                 <h3 itemprop="name">                     <a href="~/book/@item.book_id/@item.urlslug">                         @item.book_name                         @if (item.edition != 0)                         {                             switch (item.edition)                             {                                 case 1:<small class="btn btn-default btn-xs">@item.edition'st edition</small> break;                                 case 2:<small class="btn btn-default btn-xs">@item.edition'nd edition</small> break;                                 case 3:<small class="btn btn-default btn-xs">@item.edition'rd edition</small> break;                                 case 4 - 10:<small class="btn btn-default btn-xs">@item.edition'th edition</small> break;                                 default:<small class="btn btn-default btn-xs">@item.edition'th edition</small> break;                              }                         }                     </a>                 </h3>                 <p itemprop="description">                     @*@html.raw(item.book_description)*@                 </p>             </div>         }     </div>     <!-- /.row -->     <hr>     page @(model.pagecount < model.pagenumber ? 0 : model.pagenumber) of @model.pagecount     @html.pagedlistpager(model, page => url.action("author", new { authorname = viewbag.authorname, page })) </div> 

calling area :

@{     var s = model.book.author_name.tostring();     string[] auth = s.split(',');     viewbag.author = auth; } <p itemprop="author">     <i class="glyphicon glyphicon-pencil"></i> <b>author name :</b>     @for (int = 0; < auth.length; i++)     {         <a style="color:#777777" href="~/author/@auth[i]">@auth[i];</a>     } </p> 

any 1 know how fix ?

i test code in author action without return view(result.topagedlist(pagenumber, pagesize)); there no problem.i think, topagedlist has caused error. result.topagedlist(pagenumber, pagesize) null. trace it. enter image description here


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -