I would like to shorten this: http://www.example.com/desktopmodules/imm/ims_cddetail/playtrack.aspx?trackid=18353
to http://www.example.com/playtrack/18353
IIS is no help. It suggests http://www.example.com/trackid/18353 and when I choose that, it doesn't work anyway.
I created a virtual IIS directory in the main site called "playtrack" and pointed it to the proper path. But, I still am left with http://www.example.com/playtrack/playtrack.aspx?trackid=18353.
Any suggestions?
I was looking in completely the wrong place. Dotnetnuke's Configuration Manager has a section called SiteUrls. I simply entered a rule in that:
<RewriterRule>
<LookFor>[^?]*/playtrack/(\d+)</LookFor>
<SendTo>~/desktopmodules/imm/ims_cddetail/playtrack.aspx?trackid=$1</SendTo>
</RewriterRule>
I suggest you to read https://msdn.microsoft.com/en-us/library/cc668201.aspx, you will find everything that you need about the url in aspx. You must create custom route type, for more info please read the documentation of microsoft. Especially your question is answered in the topic which called "Adding routes to a web form application".
Related
I have been trying to write something for orchard which will check all requests for "_escaped_fragment_" signifying a google ajax crawling request and will perform a 301 redirect to the correct resource which needs to be looked up using the DefaultContentManager.
I had done something like this in a previous project by extending IHttpModule and registering it using
<httpModules>
<add name="GoogleRedirect" type="MyNameSpace.GoogleRedirect"/>
</httpModules>
but have found that using the same approach I can't get access to the orchard content manager.
ie. the following doesn't work
_contentManager = DependencyResolver.Current.GetService<IContentManager>();
I also noticed that Orchard uses Autofac and have been trying to get a line similar to ContainerBuilder().Build().Resolve<IContentManager>() working but the ContainerBuilder doesn't seem to be exposed anywhere?
Is there any way of accessing the DefaultContentManager without having to rewrite the code I currenty have? If not is there a special Orchard way of doing this? What is the easiest way to do it and are there any guides to doing anything similar / any bits of code I can examine? I have been reading through the documentation but not sure of the best way of doing it?
Will carry on reading anyway any help appreciated.
Update
After doing some searching I found the following post:
http://www.deepcode.co.uk/2011/05/real-world-orchard-cms-part-4-cleaning.html
Which has an example of using filters. Just in case anyone else has any problems, I found that my Themes folder was never hitting any of the break points. After comparing with another project I noticed that the theme I had created did not have its own project file. To sort this out I recreated my theme using
codegen theme MyTheme /BasedOn:TheThemeMachine /CreateProject:true /IncludeInSolution:true
No, I don't think this is possible. Any particular reason why you need to do this in a module rather than, say, a filter?
I have developers working on a site for me, they have told me there is no possible way to re-write the URL so there is no second level category e.g.
Remove "/category" from this URL http://www.somesite.com/category/page.aspx
I understand that page.aspx can simply go in the root folder on the server however I don't want to do this as adding heaps of pages will slow down server load time
Do not believe them... It's easy and can be done for example by UrlRewriter.net library which is easy to use and open source. Also they can write own rewriter which is also not more then an hour of work, for example like here.
check whether it will helpful for your requirement: URL Rewriting in ASP.NET
I posted a query for 301-redirect using ASP.NET 3.5 here:
Redirecting default.aspx to root virtual directory
Based on the replies I got there, I realized there might be a bug in ASP.NET's Request.RawUrl method which is unable to return the actual raw url (without /default.aspx) when being used in a sub-directory, i.e. the /default.aspx page is inside a subdirectory.
Can someone please shed some light on this possible bug?
Thanks,
Asif
i found a good explanation here
http://codeasp.net/blogs/vivek_iit/microsoft-net/873/301-redirect-from-default-aspx-to-site-root
Thanks
If you suspect this is a bug, then the place to go is Microsoft Connect, where you can report and discuss the bug directly with Microsoft.
Edit: I was able to reproduce the look per your comments.
I was unable to reproduce the infinite loop, however. I injected code into the Global.asax Application_BeginRequest handler of a web application and got the expected behavior of a single redirect.
There are other, and IMO much better, options for handling global redirect rules. On IIS7, I use the URL Rewrite module to configure rewrite rules in IIS. You can read more about it and download it here: http://www.iis.net/download/urlrewrite. The appeal of a solution such as this is that you can customize and update your rewrite rules without recompiling the application.
Edit: I was able to retrieve the raw URL without the default.aspx (after the redirect) by using instead:
Request.ServerVariables["CACHE_URL"]
It's worth a shot.
Have you looked at the IIS settings for your virtual directory? If there is a default document set to default.aspx then this will explain the infinite loop that you are experiencing. You are telling the website to redirect to the virtual directory without the "default.aspx" and IIS is detecting this on the next request and putting it back in ad infinitum.
Right click your virtual directory, select Properties and then the Documents tab. If default.aspx is in the list then that is what you will get. The Url of the request will be passed to the ASP.NET worker process as /folder/default.aspx rather than /folder/
This is not a bug. If IIS didn't do this, you would get a page not found error.
Sounds to me like you need to investigate URL rewriting: http://msdn.microsoft.com/en-us/library/ms972974.aspx
Is there a way that I can have different directory names per installation of a website? As in I would need to rename the directories at build time or some similar solution. I am currently using MSBuild with CruiseControl.NET.
An example would be I have a module in my website called Bug Tracking which is then in http://mysite.com/BugTracking/.
One installation wants to leave it as BugTracking and another would like to call it "Issue Tracking" for whatever reason and have it in http://theirsite.com/IssueTracking/.
Re-writer rules
You could set up a re-writer rules so you could leave the directory name the same, and just add a re-writer rule for the clients that want it call something different?
IIS7
also look at Scott's blog
Doesn't solve the problem, kind of hides it I know. but its easy :)
or
ASP.NET Routing:
Also worth looking at would be ASP.NET Routing,
Using ASP.NET Routing Without ASP.NET MVC
or
Using Routing With WebForms
I wrote a custom URL rewriting module, to take certain paths and map them to our catalog out of the database.
I am using the technique outlined in the link at the bottom of my post.
I'm using .NET 3.5. The problem is that it only works when there is a page name on the end of the original URL, but if the page name is left off, then it never even calls my handler.
So for example, the URL
http://mysite.com/folder/index.aspx works but
http://mysite.com/folder/ does not.
The one with just the folder never gets into my handler class at all. Is there something you need to do to enable folders to work properly?
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
Is a know issue when using .NET rewriting. You need to correctly configure the wildcard mapping. Here is a good link:
http://devtalk.dk/2007/03/19/Wildcard+Mapping+And+URL+Rewriting+On+IIS7.aspx
Another option will be rewriting by IIS ISAPI with regular expressions.
In my company we actually use both.
Check out this link for references:
http://www.kowitz.net/archive/2006/09/15/url-rewriting-using-ihttpmodule-vs-isapi-rewrite.aspx
I'm not sure how to solve it but the reason is becaus IIS is treating it as a directory (which it is) and doesn't have any knowledge about how to pass the folder to the ASP.NET isapi filter and trigger the .Net handler.
You could try doing it with IIS7 and inserting the handler in the actuall IIS pipeline. Or check the bottom of the article you referenced below the heading "Using RewriteModule".