MVC :: RouteUrl Relative Links Notation?
Feb 3, 2010
to pass existing route values using the RouteUrlExpressionBuilder syntax?
I mean, having a page route, say, 'Countries/Great Britain', how can I get a hyperlink with NavigateUrl="<%$ RouteUrl: RouteName=cities,country=*current*,city=London %>" without using codebehinds?
View 4 Replies
Similar Messages:
Jun 9, 2010
Have written an ASP.Net application. Part of the application deals with being able to view PDFs. The initial PDF viewed acts as an index to access other PDF documents. You click a link in the Index PDF and it jumps to another PDF file. Legal documents, agreements, etc.
This scenario works on some computers and on others it doesn't. I managed to figure out what the problem was. On some of the computers the initial Index PDF was being hosted within the browser and on some other computers it was actually jumping out of the browser and directly into Adobe Acrobat. As soon as the PDF jumps out of the browser and into Acrobat the relative links in the Index PDF stop working because it is hosted client side via Acrobat but the additional PDFs it is trying to access are on the server.
I figured out why some computers stay in browser and why some jump out. There is an option within Acrobat itself that determines this behavior. It is under Edit--> Preferences ----> Display PDF in Browser.
I am in a jam because I am not in control of the PDF documents themselves and how they are written, and I obviously have no control over the options selected in Acrobat on each and every computer. My problem is also compounded by the fact that our firm has just recently purchased a new PDF reader called Nuance that will be pushed out firm wide soon and I don't think it even has the option to have PDFs hosted in browser.
I can get what I need to work if I create the index in HTML, but the problem is I don't write the Indexes and the people who do are not trained in HTML. I can get the people who write the indexes to change from relative links to absolute links, but then I run into the problem of what if we change where we are hosting the PDF files? All the links will break again? I think we are stuck with relative URLs, but how can I make it work?
I am thinking about maybe hosting the PDFs within Silverlight?
View 2 Replies
Dec 11, 2010
I'm building a website that stores a number of articles. The URL for each articles implements URL routing in the form /Articles/{categoryid}/{articleslug}.
Some articles have links to a graphics file. The link does not specify the full path so I'm storing the graphics file at /Articles/{categoryid}/{articleslug}/graphic.jpg.
This works fine on my desktop. But when I deployed the site to a shared hosting account, the behavior is different.
Now, the link only works if I store the graphics file at /Articles/{categoryid}/graphic.jpg. In other words, on my desktop, the {articleslug} is assumed to be a directory, but on the web it is assumed to be the name of the current page.
Does anyone know why the behavior changes? You can seen an example at http://www.blackbeltcoder.com/Articles/asp/creating-website-thumbnails-in-asp-net. Both the screenshot and download link near the top are broken links.
View 10 Replies
Apr 8, 2010
I am Final Year IT Engineering student. I am Doing Content Management System in ASP.net for my college. I have given link on my master page for various pages in the application; where I have specified only relative path of those pages. When I run this project and follow any link it works well for only first time and for second time when I click any link it .net run time environment unable to find the absolute address of that page.
View 2 Replies
May 10, 2010
I am currently working on a web form where you need to make your own account. One of the required fields is where you need to fill in your postal code. I work with an RegularExpressionValidator. This exists out of 4 numbers. The first number may not be a zero. I know that I need the ValidationExpression (propertie of RegularExpressionValidator) but I don't know what to fill in.
View 1 Replies
Jan 15, 2011
I just upgraded to MVC3 final and a part of my site that used to work has totally stopped working. Any idea where my URL's have gone or how to get them back?
Global
routes.MapRoute(
"SingleArticle",
"Articles/{action}/{year}/{month}/{day}/{key}",
new { controller = "Articles", action = "Archive", year = 0, month = 0, day = 0, key = "" },
new { year = @"d{4}", month = @"d{2}", day = @"d{2}" }
);
cshtml
var routeLinkData = new {
action = "Archive",
year = item.PublishDate.Value.Year,
month = item.PublishDate.Value.Month,
day = item.PublishDate.Value.Day,
key = item.NameKey };
URL="@Url.RouteUrl("SingleArticle", routeLinkData)"
Link="<a href="@Url.RouteUrl("SingleArticle", routeLinkData)">Link</a>"
Output
URL=""
Link="<a href="">Link</a>"
View 1 Replies
Jun 28, 2010
I was reading the ASP.NET MVC Best Practices article by Rashid, and got stuck in his description of creating UrlHelper extensions. Doing this is easy enough, and I've adopted the practice into all of my projects. I noticed, however, that Rashid used Url.Content to generate the url for the home page, and Url.RouteUrl for all the other urls. Why is this? What is the difference between the two?
The link to the blog post is here:
http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx
I've used Html.ActionLink in my Views, but I'm wondering what difference it would be if I used Url.RouteUrl instead. Does anyone have a good grasp of what makes these helpers different, and where they are best used?
View 1 Replies
Jun 23, 2010
I would like to build hyperlinks into my website who implement the routing techniques from ASP.NET 4.0. but ik can't seem to find a way to use the RouteUrl with changing values
[Code]....
In the code above (part of a GridView) i would like to bind to the routename "CustomerRoute" en provide the parameter "CustomerID" which gets its value from the field "CustomerID". But his doesn't seem to work.
View 1 Replies
Mar 28, 2011
I'm currently doing something in OrchardCMS we're using URLRewrite so that if a user comes to the site from site.com or from site.com/orchard, they get the site.com/orchard page. One of the problems is that it's throwing the urls in the menu because it's using urlHelper.RouteUrl which uses the wrong context and then produces a url like site.com/page1 rather than site.com/orchard/page1. Is there either a way to tell urlHelper.RouteUrl to start from a different page than the current one, or to get the function to return the full path?
View 2 Replies
Mar 8, 2010
On MVC 1 project I had the following working:
[Code]....
I have:
[Code]....
But I get two errors:
The name 'Content' does not exist in the current contex.
The name 'Url' does not exist in the current context.
Did something changed in MVC 2 regarding these?
I have been tryng to find the solution but no luck.
View 3 Replies
Sep 9, 2010
How do you calculate a relative path in ASP.NET MVC?
View 2 Replies
Jun 21, 2010
I've got this app where I'm using an IHttpHandler to serve JSON data to my JavaScript method.
[code]....
This works fine on my "localhost" webserver, but I've also got a staging server for my clients to use. http://staging.infinitas.ws/ClientSite/
The problem that I'm having is that when the app is hosted on the staging server, the theSource is mapped incorrectly (contains /ClientSite/). I could do something like a String.Replace but I'm looking for a more elegant way of achieving this.
View 1 Replies
Apr 24, 2010
I am trying to get a FileStream from a relative path. The file is in my project, but when I try to do that it automatically appends C:\ in front of that.
1. Does the FileStream only works if the file is on a local Hard Dive?
2. Also if it works from the local hard drive, then does my application needs some permission to read the file from C Drive?
View 2 Replies
Dec 14, 2010
Possible Duplicate: Absolute path & Relative Path
When to use absolute path, relative path and what is the difference between both?
View 2 Replies
Sep 20, 2010
I have three projects inside my solution and i using some same images on all of three projects. How can i create relative path from one project to another?
View 4 Replies
May 1, 2010
My Asp.net application uses 25-30% of the CPU on a test server which has 600 MB Ram on it.
I can see the asp_wb process taking that much percentage of CPU.
This is when I am testing using one user.
How many users can the server afford then without falling over?
Is there a relationship between the CPU Usage and number of user aka if there are 2 users my application will sky rocket to 60% of memory usage?
View 1 Replies
Apr 19, 2010
what it does at the moment is return an absolute path for example h:myfile . however, this is causing me problems because when browsing to the page, it is not returning the file i need because it is looking for a h: drive which the client machine does not have. so i was thinking i need to return a relative path so the not looking straight to the h: drive and rather it is just looking for the filename. i have also created this as a virtual directory on iis which is where is looks for the file location.
View 8 Replies
Oct 6, 2010
Assuming I have a .css file with the following linebody { background-image: url('../images/bg.png') }My build process does some CSS magic and eventuall move this file from
~/Content/styles/styles.css
To
~/temp/styles.css
This invalidates the url statement in the file and needs re-written to ../Content/images/bg.pngThis is my question - given the original file location, the new file location and the background-image url in the file is there a reusable way calculate a new relative path for the image?In case someone doesn't know css urls should be relative to the css file it is contained within.
View 2 Replies
Oct 13, 2010
I was reading this article about relative time calculationThe problem is that the results are wrong due to the time offset. My webpage is Greek.So how should i modify that function to work correctly, including the GMT+2 or GMT+3 hours offset?
View 2 Replies
Dec 7, 2010
my asp.net program have to open pdf files, these files are contained in a directory named "pdf",
The problem is: The webpage doesn't find the relative directory "/pdf" ; to solve the problem I have to write the exaclty path "C:inetpubwwrootsitepdf" butI want to use only the relative path to avoid other problems.
View 1 Replies
Mar 4, 2011
What is the correct way to reference an image in ASP.NET for live deployment on IIS? The following works in dev and production:
<asp:ImageButton ID="ibnEdit" runat="server" OnClick="ibnEdit_Click" ImageUrl="~/App_Themes/Default/images/one.png" Visible="false" ToolTip="Edit" />
The following doesn't work in either: (why not?)
<img src="~/App_Themes/Default/images/two.gif" />
The following works in dev but not in production:
<img src="../App_Themes/Default/images/two.gif" />
View 2 Replies
May 6, 2010
I have an XML file named PageData.xml in my App_Data folder. I want to populate an XDocument with this file using XDocument.Load.
If I supply the full physical path it works, i.e.:
XDocument vXDoc = XDocument.Load("/Work/Project/Web/100413 Dev/App_Data/PageData.xml");
...where "Work" is a folder on my C: drive.
If I try a relative path like this, though, I get a DirectoryNotFoundException:
XDocument vXDoc = XDocument.Load("AppData/PageData.xml");
"Could not find a part of the path 'C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0AppDataPageData.xml'."
This is obviously wrong, but there must be an easy way to set the correct relative path?
View 1 Replies
Oct 29, 2010
OK, I've seen a lot of ambiguous errors, but this was is in the top 20 or so. I have a RenderPartial that looks like this:
[Code]....
When the view loads, I get this error:
The relative virtual path '~Areas/User/Views/Shared/ProjectStats.ascx' is not allowed here. That really helps. Why isn't it allowed there? What's wrong with it? Just above it I have other PartialRender calls that work without a problem. They're created exactly the same way. Here's another:
[Code]....
This works fine. I thought maybe it was due to accessing a view from another Area, but I added a partial view to that Area's folder and it still didn't work.
View 3 Replies
Jan 22, 2010
i would know if is possible and how i can retrieve the current relative path of the view that is executed. The code is in a model file (C#)
View 2 Replies
Jan 22, 2010
Suppose I have a resource located in ~/Resources/R1.png This resource's relative URL will vary depending on the current address.
For instance: If I'm at www.foo.com/A/B/C/D.aspx and the www.foo.com/A is the root path including Virtual Directory, then the path relative to the current address of ~/Resources/R1.png is ../../../Resources/R1.png
How can I get this relative path?
EDIT:
I want a web path that I can use in a web page, not a server path.
View 4 Replies