Skip to content

Fix blog permissions viewstate#225

Open
Forro-54 wants to merge 3 commits into
DNNCommunity:developmentfrom
Forro-54:fix-blog-permissions-viewstate
Open

Fix blog permissions viewstate#225
Forro-54 wants to merge 3 commits into
DNNCommunity:developmentfrom
Forro-54:fix-blog-permissions-viewstate

Conversation

@Forro-54

@Forro-54 Forro-54 commented Jul 14, 2026

Copy link
Copy Markdown

Fixes #224

Description of PR...

Changes made

  • Item 1
  • Item 2

PR Template Checklist

  • Fixes Bug
  • Feature solution
  • Other

Please mark which issue is solved

Close #

Forro-54 added 3 commits July 13, 2026 20:41
Prevent restoring dynamically generated permission-grid child ViewState after Blog permission changes.
## Summary

This pull request fixes a ViewState exception that occurs when editing Blog settings after Blog permissions have been changed.

The issue is caused by `BlogPermissionsGrid` saving and restoring the ViewState of dynamically generated child controls. After permission changes, the generated control tree can differ between requests, causing ASP.NET to throw:

```
Failed to load viewstate.
The control tree into which viewstate is being loaded
must match the control tree that was used to save
viewstate during the previous request.
```

## Root cause

`BlogPermissionsGrid` persisted the base child-control ViewState:

```csharp
allStates[0] = base.SaveViewState();
```

and later restored it using:

```csharp
base.LoadViewState(myState[0]);
```

Because the permissions grid is dynamically generated, the child-control structure can legitimately change after permission updates, making the stored ViewState invalid.

## Fix

- Do not persist dynamically generated child-control ViewState.
- Continue to persist:
  - Blog ID
  - Current User ID
  - Blog permission collection
- Rebuild the permissions grid on each request.

## Testing

Verified successfully on DNN Platform 10.3.2 / .NET Framework 4.8.

Tested by:

- Editing existing Blogs
- Creating a second Blog
- Repeated Blog permission changes
- Updating Blog settings
- Creating posts
- Editing posts
- Uploading images to posts

The fix was also validated on a production site running the unmodified Blog 6.7.1 release by replacing only `DotNetNuke.Modules.Blog.Core.dll`.
…hanges

Tested successfully on DNN Platform 10.3.2 / .NET Framework 4.8 with SQL Server.

Verified by:

editing existing Blogs
creating a second Blog
repeated permission changes
changing Blog settings
creating and editing posts
uploading images
validating on a production site running the stock Blog 6.7.1 release
@Forro-54

Copy link
Copy Markdown
Author

I hope this is done right and the fix helps.
Regards
Trevor

@Forro-54 Forro-54 closed this Jul 14, 2026
@valadas

valadas commented Jul 16, 2026

Copy link
Copy Markdown
Member

@Forro-54 any reason for closing the PR?

@Forro-54

Forro-54 commented Jul 17, 2026

Copy link
Copy Markdown
Author

Sorry my bad.
First time commit, won't make that mistake again.
The patched file does work as i have it running on my production site and several test sites.
Kind Regards
Trevor

@Forro-54 Forro-54 reopened this Jul 17, 2026
@Forro-54

Forro-54 commented Jul 17, 2026

Copy link
Copy Markdown
Author

Again, Sorry my bad.
First time commit, won't make that mistake again.
Also I hope to push some .css formatting changes I have made to make things better on mobile devices.
Especially pertain to Chrome.
I have been plodding away for several weeks on this.

Kind Regards
Trevor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlogEdit fails with “Failed to load viewstate” after changing Blog permissions on DNN 10

2 participants