Relative path in virtual directory - asp.net

I'm migrating an e-commerce app from an old php framework to ASP.NET MVC. Some products have links to other products in their descriptions. I wrote a small app to import everything from the old site to the new site and now I want to update those links too. I would like to make the links relative, but relative links won't work on localhost because the site is in a virtual directory.
Old link: http://domain/index.php?productID=1234
New link: /product/1234
The new link won't work in localhost because it will be translated to localhost/product/1234 instead of localhost/virtualdirectory/product/1234.
I've been googling for a solution for quite some time but I can't seem to find anything. Do you have any ideas about how to solve this problem?
I actually came up with a solution while writing the question, but I'm going to post this anyway, maybe you come up with a better solution.

Have you considered not running your app in a virtual directory? While it may be the default in Visual Studio, it can be changed.

The solution I came up with was using links like this: ../../product/1234

In Visual Studio, right-click on your project and click "Properties." Under the "Web" tab, enter the virtual path in the box that says "Virtual Path:"
For example, /MyVirtualPath
In your code, make sure that your links are written like "../MyVirtualPath/".

Related

No Icons in Kentico Admin Page

I'm very new to Kentico and just started using Kentico 11 for my companies CMS and have run into a lot of issues...most of which I've figured out by trial and error. The issue that comes up most often for me is that each time I create a new website with the wizard in the Admin page, no icons appear in either the dashboard or the applications list or on the top menu bar. It doesn't look like anyone has had this issue before, and I'm curious about how to fix it. I'm using IE 11.
Here is a screenshot:
As you can see from the screenshot, no icons appear anywhere in the dashboard, menu, or menu options. Please help with this issue.
these icons come from the font /App_Themes/Default/Fonts/Core-icons.woff. Check if it is loaded correctly.
A couple things can cause this:
Most common, Kentico caches static objects pretty heavy, so try a simple CTRL + F5 to see if it refreshes things.
If you have not granted access to the user running the website (granted on the app pool), there could be permissions issues with IIS not being able to get to the files it needs. Typically you grant at least read and execute permissions at the /CMS level to the IIS_IUSRS user in the file system on your machine.
Least common, the files weren't added during the install. To check this, run the installer again but in a different location like your Desktop, then spot check/compare a couple directories: /cms/cmsscripts and /cms/app_themes for any differences.
Thank you for all your help. I found the answer and it was very basic and simple. For me the problem was Internet Explorer options not being enabled.
Talking with Kentico support is what tipped me off to this fix:
In IE 11, Go to Internet Options > Security Tab > Click Custom level > Scroll down until you get to Downloads > Under Font download check Enabled.
That was it. Like I said very simple, but on a development server where everything is disabled, it made a huge difference in performance of the Kentico interface.
I hope this helps someone else.

Dreamweaver CS6 Site Setup for Test Site with MAMP and WordPress NIGHTMARE

I have been trying to set-up a test site server on Dreamweaver CS6 IDE (which I hate) to try out the Dynamically-related files theming feature. I have been attempting to do this for hours and looked at more tutorials and blogs than I can remember attempting to set-up a test site so that I can simply try out this feature but nothing seems to work.
On the Site box I have:
Site Name: test site
Local Site Folder: users/myname/Sites/wordpress/
On the Servers I have:
Server Name: Apache
Connect using: Local/Network
Server Folder: users/myname/Sites/wordpress/
Web URL: http://localhost:80/wordpress/
Advanced:
Server Model: PHP MySQL
Yet I am receiving the an Error message:
Dynamically-related files could not be resolved because the site
definition is not correct for this server
Which makes no sense to me. Can anyone explain what am I doing wrong?
"i was under the impression that this feature would somehow convert PHP syntax into HTML so that it can be easily edited..."
What in God's name gave you that impression? PHP is server-side scripting; a way for the browser to communicate with the server and database and HTML is a way for the browser to communicate with the client (you) and render things in a form which is usable by humans. There is no "conversion", as they are two universally different languages, each serving unique functions.
In order to "easily edit" PHP, the only solution is to learn PHP scripting and syntax.
MAMP's sole purpose is to install an Apache server, PHP, and mySQL on your local computer for a server-side/database framework, such as WordPress, to store information and communicate with. Essentially like creating a mini web-host on your local machine, allowing you to check the functionality of PHP based applications.
These setting are working for me:
Open the Dreamweaver Site Setup window
Select "Servers"
Server Name: localhost
Connect Using: Local/Network
Server Folder: MAMP/ /Applications/MAMP/htdocs/your_directory_name/
Web URL: http://localhost:8888/your_directory_folder/
For a full explanation: http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader_2
I have come across the same issue and found this thread.
The post that explains a bit what we want to hear is post #6 by David_Powers on 01-May-2010 at 05:31.
So to make the problem go away you can go to 'Edit -> Preferences' and disable 'Discover Dynamically-Related Files' while leaving 'Enable Related Files' activated.
Although this fixes the error display I don't quite understand what David_Powers says this function will do and if I actually want it turned on. If someone could help me realize what this option does I would appreciate it.
I don't know if this is relevant, but after many tries to figure out the Server not found error, I stumbled across MAMP Preferences on the start up page.
After clicking on Preferences, I noticed that the Document Root was pointing to username/Sites instead of MAMP/htdocs.
MAMP Preferences > Document Root > browse to select
After I set the Document Root folder to htdocs, I finally got Dreamweaver CS6 to display my php file when I clicked the Live button in split screen mode.
None of the other answers I searched mentioned setting MAMP preferences to the Document Root folder. I hope this helps.

Orchard CMS- Configure Base URL

I installed the latest version of Orchard on my dev machine using a base url of localhost/frankgiotto. Then I moved the site to www.frankgiotto.com and updated my Base URL in the settings.
Site works perfectly. I love everything about it but the one thing is that all the links on every page are mapping to www.frankgiotto.com/frankgiotto/etc and I want simply www.frankgiotto.com/etc
This is driving me insane at the moment.. help anyone!?
p.s.. Yes, I made absolutely sure that Base Url is set to www.frankgiotto.com
Interestingly enough, www.frankgiotto.com/Blog and www.frankgiotto.com/frankgiotto/Blog both work and take me to the same place. Its the same with everything else on the site.
This is little out of context, but to make the orchard urls work without any issue on local just do the following
go to Web project
open property->Web
check for "virtual path", set it empty, and all will be fine
that will make the app run without "/", hence less chance for the above issue
Yes, that is a known issue unfortunately. This is because for now links and image addresses are just stored as plain HTML in the database. Ideally, they would be stored as logical references instead and could be rebased on the production server. This feature does not exist today so what we encourage people to do is to use a port rather than a virtual directory on their dev box if they are going to deploy at the root of a domain. This way relative urls just work. In your case I'm afraid you'll have to manually rebase the existing links and change your dev box configuration.

No styles / images on asp.Net MVC 2 application

Greetings
i have a little problem with my ASP MVC application.
On my local development server everything works just fine but when i try to publish the application to an IIS 7.0 server it just displays plain pages without any styles / markups / images.
I put all those things in the /Content/ subfolder but when i try to access that folder on the production server it just returns me a 404 not found error.
I set the IIS server up with .Net 4.0 and followed the deployment guide on here: http://www.asp.net/learn/mvc/tutorial-08-cs.aspx
All views / controllers / classes seem to work just fine, the only thing which does not is the content subfolder and i cant see why.
Anyone got a suggestion what i could have overlooked or does anyone know that problem?
I had the same issue, but I found the reason why it was forcing authentication on the Contents folder.
When a user is not logged in yet, they are classified as Anonymous Authentication. In IIS7 (which is what I am using, guessing it is the same in IIS6) you need to open the authentication window in features view. Then edit the Anonymous Authentication, to use your application pool identity, or the default one, just make sure that user has permissions to read in that folder.
That fixed it for me, hope it works for you.
Well, I added the IIS_IUSRs to the project directory and found the same problem:
CSS won't load and nothing from the content folder.
But it resolved the Unable to start debugging on the web server problem.
Then, I added the IUSR to the same folder and that fixed the problem. Now, I can see images, css styles and all that stuff.
This is because you are probably using a fixed path on the src, like: ../../Content/Styles/style.css. In MVC you should use the Url helper: Url.Content("~/Content/Styles/style.css").
Using the Url helper you should have no issues.
Been pulling my hair out all night with this one.
On W2K8, MVC2, .NET 4.0, and IIS 7 (using VS 2010)
Made sure that IIS_IUSRS had full rights to the root folder but still no go - css, js, images still not being accessed in rendering the page....
and then .... so simple:
In Features view for the site - defined MIME types for .js, .css, and .jpg - and voila!
Sweet!
p.s. my 1st mvc app - and I think I'm liking it...
Check the properties of your content folders...see if they are not 'copying locally' for some reason.
The folder that your virtual directory is pointing to gave to the user "All" reading properties.

asp.net help resource location

I have a relatively simple site that I'm working up for an intranet environment. The pages have a hook to display a simple bit of text (possibly with a bit of HTML for markup purposes) for help when the user clicks a link on the page. I'm debating whether to put the help snippets in their own XML file or create a section in web.config. The site is to be deployed across several client sites and given that updating a web.config file appears to restart the site, I'm leaning toward having it in its own file. My question is where would be the best place to locate it? I'd rather it weren't easily web-accessible, so although root or some folder is an option, I'm wondering if there is a more "standard" location for files like this, App_LocalResources perhaps? Any feedback would be welcome. Thanks.
I will look at these options. I don't anticipate a lot of updates to the help file/resource, but I think as the function of the site expands, it's certainly possible. I like the idea of it being something like XML or at least editable in a text editor so that updating doesn't necessarily require VS to update the file. Thanks all!
Sounds like a perfect candidate for resx (resource) files in the App_GlobalResources folder. Those are easily editable and posted to a site without any restarts.
What about using an embedded resource? There are several tutorials around how to use embedded resources and package it up in a dll to distribute along with your website.
In my projects, I connect the web application to an online help wiki wherever possible.
The .aspx page name is used as the help page title. Once you are in the wiki, you are free to do all the wiki tricks, such as redirecting and linking
See my blog entry for technical infos.

Resources