Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Engan 430 posts 1173 karma points
    Jul 25, 2017 @ 14:20
    Tom Engan
    0

    Membership - different versions? 'this.CurrentPage' threw an exception of type 'System.InvalidOperationException'?

    Surfacecontroller:

    if (Members.IsLoggedIn() && Members.IsMemberAuthorized(allowTypes: new[] { "hiker" }))
    

    This give me no errors before in backoffice, but give me error now with a new installation of Umbraco 7.6.4.

    Can this be written in another way that works with new Umbraco installations?

  • Tom Engan 430 posts 1173 karma points
    Jul 25, 2017 @ 15:03
    Tom Engan
    0

    Debugging:

    Name:
    CurrentPage 
    
    Value:
    'this.CurrentPage' threw an exception of type 'System.InvalidOperationException'
    
    Type:
    Umbraco.Core.Models.IPublishedContent {System.InvalidOperationException}
    
  • Alex Skrypnyk 6148 posts 24097 karma points MVP 8x admin c-trib
    Jul 25, 2017 @ 21:52
    Alex Skrypnyk
    0

    Hi Tom

    Can you show all Razor code of the view?

    Thanks,

    Alex

  • Tom Engan 430 posts 1173 karma points
    Jul 26, 2017 @ 09:00
    Tom Engan
    0

    Hi Alex, this is the partial view:

    @model Neoweb.Models.HikerViewModel
    @if (TempData["updateSuccess"] == null)
    {
    <div class="register-form">
    
        @* Actionmethod with load: ReadHikerByEmail - Actionmethod with submit: UpdateHiker (controller HikerSurfaceController) *@
        @using (Html.BeginUmbracoForm<Neoweb.Controllers.HikerSurfaceController>("UpdateHiker", FormMethod.Post))
        {  
            <h2>@ViewBag.MessageToUser</h2><br />
            <fieldset>
                <div class="form-group">
                    <span class="fa fa-user-o"></span>
                    @Html.TextBoxFor(model => model.Name, new { @class = "form-control", placeholder = "Fullt navn *" })
                </div>
                <div class="form-group">
                    <span class="fa fa-venus-mars"></span>
                    @Html.DropDownListFor(x => x.SelectedGender, Model.ListOfGenders)
                </div>
                <div class="form-group">
                    <span class="fa fa-map-o"></span>
                    @Html.DropDownListFor(x => x.SelectedMunicipal, Model.ListOfMunicipalities)
                </div>
                <div class="form-group">
                    <span class="fa fa-group"></span>
                    @Html.DropDownListFor(x => x.SelectedAgeGroup, Model.ListOfAgeGroups, "Aldersgruppe", new { @class = "form-control" })
                </div>
                <div class="form-group">
                    <span class="fa fa-mobile fa-lg"></span>
                    @Html.TextBoxFor(model => model.Mobile, new { @class = "form-control", placeholder = "Mobilnr" })
                </div>
                <div class="form-group">
                    <span class="fa fa-pencil-square-o"></span>
                    @Html.TextAreaFor(model => model.Biography, new { @class = "form-control", placeholder = "Biografi" })
                </div>
                @if (Model.ViewAvatar != null) {
                    <div class="form-group">
                        <label>Opplastet&nbsp;profilbilde</label><br /> 
                        <img src="@Model.ViewAvatar" alt="@Model.ViewAvatar" style="max-width: 300px" /> 
                    </div>
                    <div class="form-group">
                        @Html.CheckBox("deleteAvatar") <label>Slett profilbilde</label>
                    </div>
                }
                <div class="form-group">
                    @if (Model.ViewAvatar != null) {<label>Bytt profilbilde</label>} 
                     else {<label>Profilbilde</label>}
                    <input type="file" name="Avatar" />
                </div>
    
                <!-- class "valmsg-wrapper": See script in Member.cshtml -->
                <div class="alert alert-danger valmsg-wrapper">
                    <a class="close" data-dismiss="alert">&times;</a>
                    @Html.ValidationMessageFor(model => model.Name, null)
                </div>
    
                <div class="form-group">
                    <button type="submit" class="btn btn-primary">Oppdater medlemsinfo</button>
                </div>
            </fieldset>
        }
    </div>
    }
    else
    {    
        <div class="alert alert-success">
            <a class="close" data-dismiss="alert">&times;</a>
            <p>Dine medlemsopplysninger er nå oppdatert</p>
        </div>
    
        <div class="form-group">
            <a class="btn btn-primary" href="/turmaal">Til turmålsiden</a>
            <a class="btn btn-primary" href="/medlem">Til medlemssiden</a>
        </div>
    }
    

    The code shows the form well in the front end, but not in the backoffice (in the new Umbraco installation). I refer partial view UpdateHiker.cshtml via partial view macro file with the same name: UpdateHiker.cshtml (as I've done with all other partial views in my previous Umbraco installation), and so is the content:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @*actionName: ReadHikerByUserName - controllerName: HikerSurface*@
    @Html.Action("ReadHikerByUserName", "HikerSurface")
    

    But now the macro in backoffice shows this message, and not the form as in my previous Umbraco installation:

    Error loading Partial View script (file: ~/Views/MacroPartials/UpdateHiker.cshtml)
    
  • Tom Engan 430 posts 1173 karma points
    Jul 26, 2017 @ 09:37
    Tom Engan
    0

    I'm experiencing repetitive issues with the entire site, and too often the message "Unable to create the virtual directory." The Web server could not be found." (but the site seems apparently ok when I get the error message this main issue described above applies).

    When I try to set it up using IIS Express instead, I've got this error message "The view found at '~ / Views / Home.cshtml' was not created." (yellow screen of death).

    Could this be associated with the rendering problem?

  • Tom Engan 430 posts 1173 karma points
    Jul 26, 2017 @ 11:50
    Tom Engan
    0

    enter image description here

  • Tom Engan 430 posts 1173 karma points
    Jul 26, 2017 @ 11:59
    Tom Engan
    0

    The same problem I've got in this view too - can't view this line in backoffice, in the new Umbraco installation, only the previous.

    @(!String.IsNullOrEmpty(Members.GetByEmail(Members.CurrentUserName).Name) ? Members.GetByEmail(Members.CurrentUserName).Name : User.Identity.Name)
    
  • Tom Engan 430 posts 1173 karma points
    Jul 28, 2017 @ 08:33
    Tom Engan
    0

    The question briefly summarized: Can this line be rewritten in a newer way?

    if (Members.IsLoggedIn() && Members.IsMemberAuthorized(allowTypes: new[] { "hiker" }))
    
Please Sign in or register to post replies

Write your reply to:

Draft