locked
Adding a new page to an existing RAZOR site RRS feed

Answers

  • User-893317190 posted

    Hi DLPmarketing ,

    As far as I know, there are methods  that relate to route name.

    @Html.RouteLink()
    @Url.RouteUrl() 

    As their names show, these two methods could specify route name.

    If you specify a route name that doesn't exist in your route config , it may cause your problem.

    Check your cshtml to see whether you specify  Prevalent29 route name.

    About your route config,  first you could check your  global.asax 's application_start method to see where your app configures your route.

    Normally , it will be

    protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
            }

    You could see it is routeconfig that configure the route.

    Then you should search for file with the name RouteConfig.cs.

    Below is the content of the RouteConfig.

     public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
            }
        }

    The MapRoute method is used to config route.

    The name property is the name of the route, check whether your  route config has a route named Prevalent29.

    If it doesn't exist , try to add a  route named Prevalent29.

       routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
    
                routes.MapRoute(
                    name: "Prevalent29",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );

    Of course , this may not solve your problem, because the url property may not be url: "{controller}/{action}/{id}".

    In this case , you should  change the url property to meet the need of your website, I could not know the  url design of your website.

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2019 1:35 AM
  • User475983607 posted

    You're looking at the built and deployed site not the source code.  You need to find the source code to make changes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2019 6:59 PM
  • User-821857111 posted

    I am not sure. Here is a link to the site -- www.divinityhomes.com

    Can you tell by looking at the source code? Sorry I am not much help, I am just the designer.

    Looking at the response headers, it is built using ASP.NET MVC 5. That being the case, you can't just add a new page. You require access to the original source code, and someone who knows MVC 5. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 8, 2019 3:52 PM

All replies

  • User409696431 posted

    The error message you show is only the message that tells you what to do in order to actually see the error message.

    Follow those instructions and see what the real, detailed error message is.

    Sunday, May 5, 2019 10:27 PM
  • User-893317190 posted

    Hi DLPmarketing ,

    By default, web site will not show detailed message to a remote client, so the error message your png shows is not enough.

    To show detailed message , please configure you website's web.config.

    https://stackoverflow.com/questions/11665322/how-to-set-web-config-file-to-show-full-error-message

    Or try to configure your iis

    https://blogs.msdn.microsoft.com/rakkimk/2007/05/25/iis7-how-to-enable-the-detailed-error-messages-for-the-website-while-browsed-from-for-the-client-browsers/

    But in this configuration ,  other client will also see the detailed error message in your website , which is not so safe.

    If you don't want other client to see  this error message , you could open your website in local machine so that you could see more error information.

    Best regards,

    Ackerly Xu

    Monday, May 6, 2019 5:07 AM
  • User-398065737 posted

    So I went to the aspnet_client folder -> system_web and the directory is empty (or files are hidden) -- no web_config file to modify. 

    Not sure where to go to find a file like this, I searched the entire volume and no file exists with that name. Thanks for your help.

    Monday, May 6, 2019 4:01 PM
  • User-398065737 posted

    OK, I was able to find it. Please see this link to the detailed error message. Can you make any sense of it? Thanks.

    http://DLPmarketing.com/websites/DivinityHomes/Screen%20Shot%202019-05-06%20at%209.08.41%20AM.png

    Monday, May 6, 2019 4:11 PM
  • User753101303 posted

    Hi,

    You don't have  web.config (not web_config) in the folder that contains this aspnet_client folder ? Or by default the error message should be written to the Windows event log so you could try :
    https://www.howtogeek.com/123646/htg-explains-what-the-windows-event-viewer-is-and-how-you-can-use-it/

    BTW do you know which ASP.NET version is used by this site ? It seems it could be a quite old version which may not allow to use Razor. It uses ASPX pages ?

    Monday, May 6, 2019 4:13 PM
  • User-398065737 posted

    Not sure which version this is using. The pages are .cshtml format. I am just trying to add one new page to the site and update the header/footer navigation. Not a coder but a designer. Just don't want to break what is already working. Thanks.

    Monday, May 6, 2019 4:28 PM
  • User-398065737 posted

    I found this in the config file 

    System.Web.WebPages.Razor, Verison=3.0.0.0

    Monday, May 6, 2019 4:36 PM
  • User-398065737 posted

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
    <package id="ActionMailer" version="0.7.4" targetFramework="net452" />
    <package id="Antlr" version="3.4.1.9004" targetFramework="net452" />
    <package id="bootstrap" version="3.0.0" targetFramework="net452" />
    <package id="CustomMvcHelpers" version="1.0.0" targetFramework="net452" />
    <package id="EntityFramework" version="6.1.3" targetFramework="net452" />
    <package id="jQuery" version="1.10.2" targetFramework="net452" />
    <package id="jQuery.Validation" version="1.11.1" targetFramework="net452" />
    <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net452" />
    <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net452" />
    <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net452" />
    <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
    <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
    <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net452" />
    <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
    <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
    <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net452" />
    <package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
    <package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Owin.Security.Twitter" version="3.0.1" targetFramework="net452" />
    <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
    <package id="Modernizr" version="2.6.2" targetFramework="net452" />
    <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
    <package id="Owin" version="1.0" targetFramework="net452" />
    <package id="Respond" version="1.2.0" targetFramework="net452" />
    <package id="WebGrease" version="1.5.2" targetFramework="net452" />
    </packages>

    Monday, May 6, 2019 4:38 PM
  • User409696431 posted

    The error is:  A route named 'Prevalent29' could not be found in the route collection.

    What kind of site is this?  Where is the routing information?  What is "Prevalnt29"?   Is it the name of your new page?

    Monday, May 6, 2019 9:43 PM
  • User-398065737 posted

    Hi Kathy:

    Prevalent 29 is the name of the new page I am trying to add to the site (it is for a home builder in Phoenix, AZ). I cannot find a file named

    < System.Web.Routing.RouteCollection.GetVirtualPath > anywhere in the site directories in order to modify.

    There is a bin folder with a slew of .dll files which I can only view in a text editor but not luck so far.

    Monday, May 6, 2019 10:30 PM
  • User-398065737 posted

    Here is a link to what I see when I am looking at the site file directories --

    http://DLPmarketing.com/websites/DivinityHomes/Screen%20Shot%202019-05-06%20at%204.07.25%20PM.png

    There are a few .dll files with filenames starting with "System.Web. ....." not sure which one would have the routing information?

    Monday, May 6, 2019 11:11 PM
  • User409696431 posted
    The bin folder contains compiled files, not files you would edit. Is this a Core site?
    Monday, May 6, 2019 11:45 PM
  • User-398065737 posted

    I am not sure. Here is a link to the site -- www.divinityhomes.com

    Can you tell by looking at the source code? Sorry I am not much help, I am just the designer.

    Tuesday, May 7, 2019 12:07 AM
  • User-893317190 posted

    Hi DLPmarketing ,

    As far as I know, there are methods  that relate to route name.

    @Html.RouteLink()
    @Url.RouteUrl() 

    As their names show, these two methods could specify route name.

    If you specify a route name that doesn't exist in your route config , it may cause your problem.

    Check your cshtml to see whether you specify  Prevalent29 route name.

    About your route config,  first you could check your  global.asax 's application_start method to see where your app configures your route.

    Normally , it will be

    protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
            }

    You could see it is routeconfig that configure the route.

    Then you should search for file with the name RouteConfig.cs.

    Below is the content of the RouteConfig.

     public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
            }
        }

    The MapRoute method is used to config route.

    The name property is the name of the route, check whether your  route config has a route named Prevalent29.

    If it doesn't exist , try to add a  route named Prevalent29.

       routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
    
                routes.MapRoute(
                    name: "Prevalent29",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );

    Of course , this may not solve your problem, because the url property may not be url: "{controller}/{action}/{id}".

    In this case , you should  change the url property to meet the need of your website, I could not know the  url design of your website.

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2019 1:35 AM
  • User409696431 posted

    No, you can't tell by looking at the source.  The source is just HTML, CSS, and JavaScript - the stuff sent to the browser.

    I can't be of any help here.  You need someone who knows how that site is created.

    Tuesday, May 7, 2019 1:46 AM
  • User-398065737 posted

    Hi Ackerly:

    Thanks for your detailed and well-explained reply. Unfortunately, I cannot find any RouteConfig.cs files and the global.asax file only has one line of code in it. I will reach out to the original developer to see if they can help me.

    Tuesday, May 7, 2019 5:18 PM
  • User-398065737 posted

    Hi Kathy:
    I appreciate your efforts. Thanks for trying.

    Tuesday, May 7, 2019 5:18 PM
  • User475983607 posted

    You're looking at the built and deployed site not the source code.  You need to find the source code to make changes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2019 6:59 PM
  • User-821857111 posted

    I am not sure. Here is a link to the site -- www.divinityhomes.com

    Can you tell by looking at the source code? Sorry I am not much help, I am just the designer.

    Looking at the response headers, it is built using ASP.NET MVC 5. That being the case, you can't just add a new page. You require access to the original source code, and someone who knows MVC 5. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 8, 2019 3:52 PM