Path problems with running a sub application (umbraco) inside my MVC4 web application - asp.net-mvc-4

I have this MVC4 web application, I run it locally at mySite.local/. I created an application in IIS 7, mapping to mySite.local/corporateSite/. I point that application to an Umbraco (CMS) installation I have locally.
This works pretty well.
I have these UI images and .css files that were in my corporate site and were linked-to by absolute urls (Examples: /css/myCss.css, /media/ui/myFunLogo.png, etc.).
Now this "/" root has changed, if I want my css and images to work, I have to use /corporateSite/cssmyCss.css... this is logical.
How can I change my configuration or sites setup or code so that I don't have to write that whenever I'm linking to a file like that. Should I use rewrite rules to prepend the application url?
How to people integrate these elements normally ? I know a lot go through subdomains, but this would not be ideal for us at the moment.
Thanks for the help!
(I think my question is related to this one how to integrate umbraco with mvc4 but in some different aspects. And the answers are not good for me.)

In umbracoSettings.config, there is a setting for "ResolveUrlsFromTextString".
Setting it to true should tell Umbraco to add the virtual directory name to links and images.

Related

Is there a difference in page paths when on localhost verses deployed?

My app is created in next.js and works great in localhost. When I deployed it in heroku, only the front page shows up and all page paths do not work even though they are correctly inputted in the browser. The only page that is connected to the index.js file in my page paths is the front page. Do the other pages need to also be connected to the indec.js file? I am terribly lost with this issue since the site works perfectly in localhost. In heroku every page path besides / has a 404 error. I didn't add any code to this question since no one file seems relevant to the issue. I've been searching all over for an answer to this issue but can't seem to find any relevant information online since the app is deployed successfully it just won't render any file paths besides /.
Thank you in advance for any help you can offer. I really appreciate it!
Applications are ran differently on localhost and when deployed to the server. Since you added react tag on the post, I assume you are trying to deploy react native app on Heroku, there is lots of information on internet how to do it.
For example this post.
Anyway first you need to build your app correctly, so static files would be generated (you didn't mentioned how you are running that app).
To your question:
Relative paths are the same on both local and server, but absolute paths will be different.
But for your 404 error I see that no static content are found on the root path.

Add CSS File to WebCenter Sites application

I have a WebCenter Sites installation. Separately, I have site.js and site.css files. How can I make a WebCenter Sites template use these two files? Where do i put those files so they can be consumed?
What I've done so far is set up a simple HTTP server outside of WebCenter Sites and used <link> and <script> tags to point to those files on the external server. This does indeed work, but I prefer having the files served from the sites application.
I see sites exposes a CSS type asset, but it seems to be tied to their widget framework. I was thinking to just make an empty widget with CSS, then I could reference the widget/asset in the <link href=. Again there aren't many examples of this online.
Can anyone give me some ideas on how to serve files from within WebCenter Sites?
There are alternatives to storing files directly in the webapp, such as using a custom basic assettype to contain the files, and then delivering them via blobserver (or just rendering inline). The advantage to this is that you are managing assets to keep environments in sync, rather than updating the webapp & redeploying.
The path needs to be relative to the web application context. There are probably better ways to reference it in Sites, but the lowest-common denominator approach that will work for all J2EE web applications is to use pageContext.request.contextPath, so the link would look like:
href="${pageContext.request.contextPath}/src/stylesheets/css/styles.css"
So if this were used with a JSK, the src folder would be under [JSK_HOME]\App_Server\apache-tomcat-7.0.42\Sites\webapps\cs

How to make use of common files across projects using an IIS7 virtual directory

The scenario:
I'm very new to ASP.Net MVC programming and running into a wall constantly trying to make use of common files (.js, .css) across multiple projects.
The idea is to have these generic files in 1 location which provides for easy future updates and avoids the "copy and paste" dilemma across all the projects. I've set this folder up in IIS7 as a virtual directory in the default website with an alias "CommonFiles".
The problem:
With MVC-4 I'm trying to add the js files to a script bundle but upon running the application it's not picking the files up at all. (checked in the page source and also added a js function as a test)
Code snippet in BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/test").Include("~/CommonFiles/test.js"));
Rendering in _Layout.cshtml:
#Scripts.Render("~/bundles/test")
I've read quite a few posts (
Script Bundling in WebForms with Virtual Directories (asp webforms though), How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app, ScriptBundle not rendering scripts that are in a VirtualDirectory) but i'm afraid my lack of knowledge on MVC is limiting my path forward and really hoping to get some insight into how MVC handles IIS virtual directories and if it's even an easy possibility given the last post i've read above.
Can this be done in MVC-4 and if not what is a second best alternative in reusing common code across projects?
After reading a post by kev (Using ServerManager to create Application within Application) it put me on the right path and the issue I had is actually embarrassing.
For the sake of other devs landing on this post with a similar issue in visual studio, this is what fixed my issue:
Problem:
I make use of a separate project which contains files that are used across multiple other projects. I created a virtual folder in IIS7 referencing these files. This means if a change is needed to the common files, it's updated once and all the other projects will automatically "see" the change.
My other individual projects make use of script bundling to include files relevant only to the said project, but also to reference the common files in the virtual folder as defined in IIS.
My MVC-4 web application wasn't picking up the common files given the syntax above, in neither debug or release..
Solution:
When developing in VS2012, under the project's properties, there's a setting under the web tab where you can specify whether you want to use local IIS web server or IIS Express to test your application. IIS Express adds a random port to the site in order to test, and to allow multiple instances of sites to run (on different ports). This seems to throw the virtual directory include off in the bundling.
Choosing to use the local IIS server is closer to what the "live" environment would be in my opinion. Just un-tick the "Use IIS Express" setting.
As a side note and for more info on what the difference between the usage of IIS and IIS express is and whether it's suitable for your environment (as it was for mine) see this link:
http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx
Hope this helps someone in future and saves them the amount of time I wasted on this!

"Hack" in to localhost root directory from a VM web app

I have apache VM web app running locally. It's red hat.
It's PHP based but the main page is index.html. I am able to to into sub-directories for images and such, I wanted to know if it is possible for me to gain access to the directories that contain the php code, probably just one level above the images directory. Because of index.html, it forces the load, and I am unable to see server files.
Yes there used to be a trick called dot-dot-traversal that could do this. Basically you put two dots into a URL and climb above the web root. Something like http://www.example.com/../../../../etc/shadow . Occasionally a new way to exploit the vulnerability is discovered, but mostly it is rare. Unless you're running an old server, you should be pretty safe.

OS X Lion - Website sharing , display directory files

I need some help to get Mac WebSite sharing to work as i want.
Basically i need to know how i can make it display the files of a directory.
Do i need to make a website to show my directory files or is there any other way ?
And if i do need to make a website to display my directory, what code should i use to do so ?
I am no expert on HTML at all.
Allso, i have been searching around for this and i couldn't find any answers related to my question.
You need to turn indexes on in your Apache config. This could be on by default. Check to see if you have folder named Sites in your home directory. If you do rename the index.html page (if there is one) and then navigate to http://localhost/~yourusernamehere.
The same applies if you are using the default apache directory (the system wide one) which is located in /Library/WebServer/Documents if I remember correctly. In this case you would navigate to http://localhost. I just checked on my system (OS X 10.7) and the indexes were enabled by default.
You will need to use a server-side language such as PHP, Java, ASP.NET if you want to display the 'servers' directory on a web page. I will say because you're a begineer use PHP as it's very easy to learn...
Download MAMP / XAMPP.
Research PHP and follow some tutorials first, and then implement directory searching and output it as HTML.
http://php.net/manual/en/ref.dir.php
Code:
http://css-tricks.com/snippets/php/display-styled-directory-contents/