Copied to clipboard

Flag this post as spam?

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


  • Kamil 7 posts 68 karma points
    Oct 23, 2014 @ 14:26
    Kamil
    0

    Not working in Umbraco 7.1.6 MVC

    Hello,

    I have installed this plugin and configured using each option: doctypes, templates and ID's and it just seems to not execute at all. Can anyone confirm if this plugin should work in 7.1.6 MVC?

    Thanks a lot.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 23, 2014 @ 19:04
    Jan Skovgaard
    0

    Hi Kamil

    Have you tested the package using a server, which has been SSL enabled? If not then perhaps this blogpost by Scott Gu might help? http://weblogs.asp.net/scottgu/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates

    Hope this helps.

    /Jan

  • Kamil 7 posts 68 karma points
    Oct 24, 2014 @ 12:08
    Kamil
    0

    Hi Jan,

    Thanks for the reply.

    I have tested it on a localhost with self signed certificate as described in the blogpost. When I type the URL manually like:

     https://mypcname/MVC-Umbraco/uk/log-in

    it redirects to the correct page, so I assume this means the certificate on the server works fine. If I redirect to this page using a link or just typing the url without https:// then it just goes to standard http.

    Now I have encountered an issue when installing the package. My websites main directory is "MVC-Umbraco", the installer has created additional folder inside main directory with the same name "MVC-Umbraco" and folders "bin" and "umbraco" inside of it. I have moved those 2 folders back to the main directory and then the plugin started to work. I wonder if that might affect it's functionality.

    Thanks for your help,

    Kamil

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 26, 2014 @ 17:40
    Jan Skovgaard
    0

    Hi Kamil

    Ok, so what is your project setup exactly? Are you using virtual directories etc.? Not sure I'm getting it :)

    But happy to see you figured something out that seems to get it working.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 27, 2014 @ 09:17
    Jan Skovgaard
    0

    Hi Kamil

    Maybe you can just do as Sebastiaan describes in this post? http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/57637-Auto-redirect-to-HTTPS-for-some-pages-in-MVC?p=0#comment196702 - That way you don't need to rely on a package.

    /Jan

  • Kamil 7 posts 68 karma points
    Oct 27, 2014 @ 17:08
    Kamil
    0

    Thanks Jan,

    I have figured a workaround very similar to the one from the post above.

    Thanks for your help.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 27, 2014 @ 20:40
    Jan Skovgaard
    0

    Hi Kamil

    Ok, sounds good - Happy you managed to figure out a workaround. Do you mind sharing btw if it's some code others could benefit from if they come across this post? :)

    /Jan

  • Kamil 7 posts 68 karma points
    Nov 04, 2014 @ 11:45
    Kamil
    101

    Hi Jan,

    I'm sorry, I was busy at work and haven't visited the forum for a week. Here is what I have done to enable the https on some pages only:

    Following the documentation: http://our.umbraco.org/documentation/Reference/Mvc/custom-controllers I have created the custom controller that inherits from RenderMvcController. Now all the pages are being routed through it. Then I have added a "Requires https" bool property to the master document type in the back office, so I can enable/disable it for each page. The custom controller is checking the property and is redirecting to https: if required. Here is the code:

    using System;
    using System.Web;
    using System.Web.Mvc;
    using MVC_Umbraco.Extensions;
    using umbraco;
    using umbraco.NodeFactory;
    using Umbraco.Web.Models;
    using Umbraco.Web.Mvc;
    
    namespace MVC_Umbraco.Controllers
    {
        public class CustomRenderMvcController : RenderMvcController
        {
            public override ActionResult Index(RenderModel model)
            {
                if (!RequiresHttps(this.Request) && (Request.Url.Scheme == Uri.UriSchemeHttps))
                {
                    var httpuriBuilder = new UriBuilder(Request.Url.ToString())
                    {
                        Scheme = Uri.UriSchemeHttp,
                        Port = -1 // default port for scheme
                    };
                    return Redirect(httpuriBuilder.ToString());
                }
    
                if (!RequiresHttps(this.Request))
                    return base.Index(model);
    
                if (Request.Url.Scheme == Uri.UriSchemeHttps)
                    return base.Index(model);
    
                var uriBuilder = new UriBuilder(Request.Url.ToString())
                {
                    Scheme = Uri.UriSchemeHttps,
                    Port = -1 // default port for scheme
                };
                return Redirect(uriBuilder.ToString());
            }
    
            private bool RequiresHttps(HttpRequestBase req)
            {
                try
                {
                    Node n = uQuery.GetNodeByUrl(req.RawUrl);
                    if (n == null)
                        return false;
                    return n.GetPropertyData<bool>("requiresHttps");
                }
                catch (Exception)
                { }
                return false;
            }
    
        }
    }
    

    Thanks,

    Kamil

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 05, 2014 @ 20:18
    Jan Skovgaard
    0

    Hi Kamil

    That's awesome! Thanks for sharing :)

    I think you should mark your own last post as the correct answer so others who come across this can jump directly to your solution and benefit from it.

    H5YR! (High five you rock).

    Cheers, Jan

Please Sign in or register to post replies

Write your reply to:

Draft