?
Solved

Url in c# razor webpage

Posted on 2014-10-03
9
Medium Priority
?
156 Views
Last Modified: 2014-10-03
Hi.

I want my page to have the urlstructure like this:
www.domain.com
www.domain.com/categoryname
www.domain.com/categoryname/product
how does it work. It seems like there need to be a psyical file like:
www.domain.com/category/catogoryname
www.domain.com/product/productname
where category and product is .cshtml files.
0
Comment
Question by:bongii
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40359301
Are you writing a Web Forms or MVC application (or a Web Site project)?
0
 

Author Comment

by:bongii
ID: 40359302
Web Site project
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40359308
Just to be absolutely sure:  When you say "Web Site", you created your project like this, yes?

Screenshot
0
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 

Author Comment

by:bongii
ID: 40359328
Yes :)
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40359418
Well Web Sites don't use the routing engine that MVC comes with, so they more or less work like traditional web pages. Short of writing your own custom module, or *maybe* importing one of the MVC modules, I think URL rewriting would probably be the easiest route to go. I would start at the official ASP.NET web site for more information:

http://www.iis.net/learn/extensions/url-rewrite-module

The gist of it will be that you put your simplified URLs in your Razor--probably by hand rather than through the default helpers; or perhaps you can write a helper--and you set up your rewrites to manipulate these URLs into what the web server expects to see.
0
 

Author Comment

by:bongii
ID: 40359424
Ok. I´ve tried in global asa, but gets an error:  
Mente du: Typen 'ASP.Page Default Cshtml' nedarves ikke fra 'System.Web.UI.Page'.
Type 'ASP._Page_default_cshtml' not inherited from 'System.Web.UI.Page'.


void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }

    void RegisterRoutes(RouteCollection routes)
    {
        // redirects
        routes.MapPageRoute("hello", "hello", "~/default.cshtml");
    }
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40359450
I don't think that will work because you're attempting to mix MVC and Web Site architectures. It may, but I wouldn't know where to begin in order to make it work. Someone else might.
0
 

Author Comment

by:bongii
ID: 40359466
Ok. So it´s not possible to make the routes to files in folders?
It only work if the name is a file in main path?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40359467
I'm saying that I don't believe you can use anything to do with routes because you are not working in an MVC project.
0

Featured Post

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question