ForumOptions.cshtml line 19 gives nullreferenceexception

May 27, 2012 at 12:46 AM

Hi there,

I am trying to deploy the application to a Windows 2003 server and I get the error  System.NullReferenceException: Object reference not set to an instance of an object on line 19. However when I publish it on my test server the application works fine. I get the same error even if i copy exactly everything to the production server.

Line 17: 	{
Line 18: 		<span>/</span>
Line 19: 		@Html.ActionLinkLocalized("Most viewed threads", "MostViewedTopics", new { page = 0 }, IsAction("MostViewedTopics") ? new { @class = "selected" } : null)
Line 20: 	}
Line 21: 	@if (Config.UI.DefaultForumSort != ForumSort.LatestActivity)

Below is the stack trace:

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   NearForums.Web.UI.BaseViewPage`1.get_ActionName() +58
   NearForums.Web.UI.BaseViewPage`1.IsAction(String actionName) +12
   ASP._Page_Views_Forums_ForumOptions_cshtml.Execute() in d:\inetpub\gametolia.com\forums.gametolia.com\Views\Forums\ForumOptions.cshtml:19
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +279
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +113
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName) +31
   ASP._Page_Views_Forums_Detail_cshtml.Execute() in d:\inetpub\gametolia.com\forums.gametolia.com\Views\Forums\Detail.cshtml:25
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.StartPage.RunPage() +19
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +65
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

 

Coordinator
May 27, 2012 at 1:28 PM
Edited May 27, 2012 at 1:29 PM

Hi,

I'm looking into it, but I can not reproduce it (even the sample site is a Win2003 server...) 

Could you answer some questions:

  1. Which version of the .NET are you using on IIS website (it should be .net4) ?
  2. Are you able to run any other webpage of nearforums, for example http://yourhost/p/about?
  3. Are you using a Fork (modified version) of Nearforums or you are using Nearforums from a release?

Can you deploy to the bin directory the following dlls (included in the release):

  • System.Web.Helpers.dll
  • System.Web.Mvc.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll

 

Thanks for the detailed report!

Kind Regards,

Jorge

May 27, 2012 at 3:22 PM

 

Hi Jorge,

  1. Which version of the .NET are you using on IIS website (it should be .net4) ?
    It is .net4

  2. Are you able to run any other webpage of nearforums, for example http://yourhost/p/about?
    Login etc works but I haven't tested the link you mentioned

  3. Are you using a Fork (modified version) of Nearforums or you are using Nearforums from a release?
    Nope, it is not a modified version. Itis whatever I downloaded from codeplex.
  4. The dlls you menton are already there
I have no idea why I have the problem on one server and not on the other because the test server and production server are identical :/
Anyway this is what I did to overcome the problem: 
I downloaded the source code and changed the code in (NearForums.Web\UI\BaseViewPage.cs line 141) to what I have below and I dont have the problem anymore:
public string ActionName
{
 get
   {
      if (ViewContext.RouteData.Values["action"] != null)
      {
        return ViewContext.RouteData.Values["action"].ToString();
      }
      return string.Empty;
    }
}
-d
Coordinator
May 28, 2012 at 7:44 AM

Hi,

The solution you applied is good: the weird thing is that RouteData.Values["action"] should never be null!

Anyway, We will do the same to be sure.

 

Kind Regards,

Jorge

Jun 5, 2012 at 12:50 PM
Jorge,

The funny thing is I dont get that error on my test server however I get the error on the production server. Both machines are ideantical as far as I know.

However I am having different issues now even thoughI managed to fix that one specific error :(

So far this is what I did:
  1. I downloaded the recommended Near Forums and DB scripts and I had the error I mentioned previously.
  2. So I downloaded the source code for v.8.0.0.2. I set it up successfullly applied the fix I mentioned, recompiled and published the app and it stopped giving me the error related to RouteData.Values["action"] .
  3. So I created some content.
  4. Now even though I make the content available to necessary user groups or even to everyone, when I want to post via regular authenticated user it says access denied and I have to me moderator? However there is no such restriction at the moment.
  5. When I login as admin and post a message it sends me to ....../admin/messages/flagged adress and tells me "No flagged Messages found"
you can test the forum at forums.gametolia.com. It's membership is integrated with another apps database and FB login is also working. There is content you can reply to in http://forums.gametolia.com/genel-tartma-sohbet/mars-hakknda-1/

I am really puzzled... I look at the sample forum and none of these errors exist. If we cannot fix this issue in a few days I'll have to switch to some other forum soft, which is a pitty because I really like to use nearforums :/

Deniz Torlak
....................................................................................
tel : +90 (216) 537 89 37 (pbx)
mobile : +90 (533) 699 7006
fax : +90 (216) 537 89 33
email : deniztorlak@gmail.com
web : http://www.deniztorlak.com
meeting : https://connectnow.acrobat.com/deniztorlak
....................................................................................
P Yazıcıya bastırmadan önce bir kez daha düşününüz.



On Mon, May 28, 2012 at 10:44 AM, jorgebg <notifications@codeplex.com> wrote:

From: jorgebg

Hi,

The solution you applied is good: the weird thing is that RouteData.Values["action"] should never be null!

Anyway, We will do the same to be sure.

Kind Regards,

Jorge

Read the full discussion online.

To add a post to this discussion, reply to this email (nearforums@discussions.codeplex.com)

To start a new discussion for this project, email nearforums@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Coordinator
Jun 5, 2012 at 1:35 PM
Edited Jun 5, 2012 at 1:40 PM

Hi Deniz,

What you mean by: I download the source code for the version 8.0.0.2?
Kind Regards,
Jorge
Coordinator
Jun 5, 2012 at 1:41 PM
Edited Jun 5, 2012 at 1:47 PM

Also, Could you execute this query and post the result set?

select ReadAccessGroupId, PostAccessGroupId, * from TopicsComplete

select ReadAccessGroupId, PostAccessGroupId, * from Topics

(At least for the Topic you are talking about)

Coordinator
Jun 5, 2012 at 1:59 PM

You can now replace your dlls from your fork with the release (I included the check for nulls on RouteData Values of the ViewContext)

Jun 5, 2012 at 2:09 PM
Hi Jorge,

Sorry my mistake it is the version tagged as V8.0 not 8.0.0.2.

Deniz Torlak
....................................................................................
tel : +90 (216) 537 89 37 (pbx)
mobile : +90 (533) 699 7006
fax : +90 (216) 537 89 33
email : deniztorlak@gmail.com
web : http://www.deniztorlak.com
meeting : https://connectnow.acrobat.com/deniztorlak
....................................................................................
P Yazıcıya bastırmadan önce bir kez daha düşününüz.



On Tue, Jun 5, 2012 at 4:35 PM, jorgebg <notifications@codeplex.com> wrote:

From: jorgebg

Hi Deniz,
What you mean by: I download the source code for the version 8.0.0.2?

Kind Regards,
Jorge

2012/6/5 deniztorlak <notifications@codeplex.com>

From: deniztorlak

Jorge,

The funny thing is I dont get that error on my test server however I get the error on the production server. Both machines are ideantical as far as I know.

However I am having different issues now even thoughI managed to fix that one specific error :(

So far this is what I did:
  1. I downloaded the recommended Near Forums and DB scripts and I had the error I mentioned previously.
  2. So I downloaded the source code for v.8.0.0.2. I set it up successfullly applied the fix I mentioned, recompiled and published the app and it stopped giving me the error related to RouteData.Values["action"] .
  3. So I created some content.
  4. Now even though I make the content available to necessary user groups or even to everyone, when I want to post via regular authenticated user it says access denied and I have to me moderator? However there is no such restriction at the moment.
  5. When I login as admin and post a message it sends me to ....../admin/messages/flagged adress and tells me "No flagged Messages found"
you can test the forum at forums.gametolia.com. It's membership is integrated with another apps database and FB login is also working. There is content you can reply to in http://forums.gametolia.com/genel-tartma-sohbet/mars-hakknda-1/

I am really puzzled... I look at the sample forum and none of these errors exist. If we cannot fix this issue in a few days I'll have to switch to some other forum soft, which is a pitty because I really like to use nearforums :/

Deniz Torlak
....................................................................................
tel : +90 (216) 537 89 37 (pbx)
mobile : +90 (533) 699 7006
web : http://www.deniztorlak.com
meeting : https://connectnow.acrobat.com/deniztorlak
....................................................................................
P Yazıcıya bastırmadan önce bir kez daha düşününüz.



On Mon, May 28, 2012 at 10:44 AM, jorgebg <notifications@codeplex.com> wrote:

From: jorgebg

Hi,

The solution you applied is good: the weird thing is that RouteData.Values["action"] should never be null!

Anyway, We will do the same to be sure.

Kind Regards,

Jorge

Read the full discussion online.

To add a post to this discussion, reply to this email (nearforums@discussions.codeplex.com)

To start a new discussion for this project, email nearforums@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (nearforums@discussions.codeplex.com)

To start a new discussion for this project, email nearforums@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (nearforums@discussions.codeplex.com)

To start a new discussion for this project, email nearforums@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Jun 5, 2012 at 3:29 PM
jorgebg wrote:

Also, Could you execute this query and post the result set?

select ReadAccessGroupId, PostAccessGroupId, * from TopicsComplete

select ReadAccessGroupId, PostAccessGroupId, * from Topics

(At least for the Topic you are talking about)

Here you go;

select  * from Topics

TopicId TopicTitle TopicShortName TopicDescription TopicCreationDate TopicLastEditDate TopicViews TopicReplies UserId TopicTags ForumId TopicLastEditUser TopicLastEditIp Active TopicIsClose TopicOrder LastMessageId MessagesIdentity ReadAccessGroupId PostAccessGroupId
1 M.A.R.S. Hakkında mars-hakknda   2012-05-29 11:21:58.610000000 2012-05-29 11:21:58.610000000 12 0 6 m.a.r.s. 4 6 78.186.161.31 -1 0     0   1  

select * from TopicsComplete

TopicId TopicTitle TopicShortName TopicDescription TopicCreationDate TopicViews TopicReplies UserId TopicTags TopicIsClose TopicOrder LastMessageId UserName ForumId ForumName ForumShortName ReadAccessGroupId PostAccessGroupId
1 M.A.R.S. Hakkında mars-hakknda 2012-05-29 11:21:58.610000000 12 0 6 m.a.r.s. 0     GametoliaForumAdmin 4 Genel Tartışma & Sohbet genel-tartma-sohbet 1


Jun 5, 2012 at 3:33 PM

I'll re-download the release (recommended download pack) and see it works. But even if it works I'd be glad if we can figure out why it does unexpected stuff when I compile the source code :) We might have to customize certain things.

I really appreciate your help Jorgeb, thanks a lot.

- Deniz 

Coordinator
Jun 5, 2012 at 3:37 PM

Hi Deniz,

Happy to hear that it works!

(The different version should probably be the because of the branching on the repository: version-008 vs default)

 

Kind Regards,

Jorge

Jun 5, 2012 at 3:48 PM

I downloaded the latest release pack and I get the same results as I do when I download the version 8, apply the null fix, compile and publish.

FYI: the facebooklogin stopped working when I published the latest release (I used the same web.config not the one comes with the pack) it started working as soon as I converted back to my fork. 

:/

Jun 5, 2012 at 3:55 PM
jorgebg wrote:

Hi Deniz,

Happy to hear that it works!

(The different version should probably be the because of the branching on the repository: version-008 vs default)

 

Kind Regards,

Jorge

Jorge,

I am sorry to inform you that I still have the same problems.

To apply the fix I am downloading the source code for version-008 not the "default" assuming that the one I downlod is the stable version 8, right?

-deniz

Coordinator
Jun 5, 2012 at 5:35 PM

Sorry, I don't understand...

Why aren't you using the dll's included in the release?

Which fix are you applying?

Jun 14, 2012 at 2:32 PM
Jorge,

Actually I am using the dlls in the release. I downloaded the final version today after your email. It seems the error I mentioned in the first place is fixed after your update (This is the fix I am talking about, I was fixing the same issue when I forked the source code. )

However when I use the dlls in the release and want to post as a member user, I get

Access Denied
" You must belong to the role Moderator to perform this action. "

and when I want o post as Admin user I get

Flagged Messages
"No flagged messages found."

and when I want o post as Admin user I get

Flagged Messages
"No flagged messages found."


This is the same message I get when I download the version 8 source code and compile and publish. Even I delete all the users and all the threads and create everything from scratch I get the same message. I don't put restriction to any thread all of them can be read by everyone and accept post from member. I have not set anything related to moderator etc.

I have tried everything. Even deleted everything and made a vanilla installation with nothing set other than the conenction string.

still I get the same messages and cannot post a reply to a thread :(

.d