C# - Transform URL Without Routing Or Rewrite?
Jan 13, 2010
I am using ASP.NET 2.0 on IIS6 therefore I can't use system.web.routing. I've tried a few URL rewriters but none did what I wanted.I basically need to transform (read/parse then redirect) URL 1 into 2 with minimum IIS configuration because I don't have the full authority to reconfigure web servers (i.e. ISAP on IIS6 or install 3rd party extensions/libraries). And I can't transform URL into 3 because all the physical links will break. [URL]
View 3 Replies
Similar Messages:
Dec 15, 2010
ASP.net 4.0 / IIS7.
I want to "alias" a single web form to appear as various extensionless urls. Given a form in my web root called "mySite.com/ColorWebForm456.aspx":
I want it served as multiple names, e.g., mySite.com/Color, mySite.com/Colour, mySite.com/Colors, mySite.com/Coler, etc., without creating folders and duplicate forms with those names.I never want mySite.com/ColorWebForm456.aspx displayed in the browser, it needs to display as mySite.com/Color, even if the user somehow acquires it and types in that exact ~.aspx address. The variations will account for several alternate or mis-spellings users might attempt - I don't want them "corrected", however. So, if a user types in mySite.com/Colour, the url is NOT rewritten to mySite.com/Color, but the same page is served via ColorWebForm456.aspx as the requested "mySite.com/Colour".
I've seen so many articles on this that I'm not even sure where this would be best handled: in Global.asax, IIS7 URL Rewrite, web.config, etc., and I'm not even sure this is technically a case of url rewriting or routing... ?
View 4 Replies
Jan 12, 2010
I am using System.Web.Routing with ASP.NET (3.5) Web Forms that will URL rewrite the following URL from
http://www.myurl.com/campaign/abc
http://www.myurl.com/default.aspx?campaign=abc
The code is as below:
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add("CampaignRoute", new Route
(
"{campaign_code}",
new CustomRouteHandler("~/default.aspx")
));
}
IRouteHandler implementation:
public class CustomRouteHandler : IRouteHandler
{
public CustomRouteHandler(string virtualPath)
{
VirtualPath = virtualPath;
}
public string VirtualPath { get; private set; }
public IHttpHandler GetHttpHandler(RequestContext
requestContext)
{
if (requestContext.RouteData.Values.ContainsKey("campaign_code"))
{
var code = requestContext.RouteData.Values["campaign_code"].ToString();
HttpContext.Current.RewritePath(
string.Concat(
VirtualPath,
"?campaign=" + code));
}
var page = BuildManager.CreateInstanceFromVirtualPath
(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
}
However I noticed there are too many things to change on my existing aspx pages (i.e. links to javascript, links to css files).
So I am thinking if there's a way to keep above code but in the end rather than a rewrite just do a Request.Redirect or Server.Transfer to minimize the changes needed. So the purpose of using System.Web.Routing becomes solely for URL friendly on the first entry.How to ignore the rest of the patterns other than specificed in the code?
View 1 Replies
Feb 19, 2010
I have implemented my own IRouteHandler for URL routing. For files without extension it will try to load the filename as a Page from the Pages directory with:
return (IHttpHandler) BuildManager.CreateInstanceFromVirtualPath(path, typeof(Page));
However there are also images and css files (with relative paths) that need to be translated to the correct url. I try to service those files with:
try {
HttpContext.Current.Server.Transfer(fileName);
} catch (HttpException) {
throw new HttpException(404, "file not found");
}
This works fine (in Internet Explorer), however Firefox is giving me an error:
Styles.css was not loaded because its MIME type, "text/html", is not "text/css".
Is this caused by the Server.Transfer? What should I use to redirect the file? Response.Redirect is visible to the client.
View 1 Replies
Sep 13, 2010
we are using URL Routing so a path like
[URL] would be output like [URL]
we have a data pager on the page that ties to the list view.
the data pager when changing pages reverts the url back to the un-routed version (like[URL])
how can i re-write this back to something more friendly for my app
ideally it would be great to have it look sometihng like /news/page/2
i can use IIS 7's new re-write module - already using it to remove trailing slashes.
View 2 Replies
Jul 20, 2010
I tried everything I could find, but still does not work on IIS routing.
View 2 Replies
Nov 4, 2010
i am new with linq and i wanna do something like this in linq:
[Code]....
how can i do this?
View 2 Replies
Dec 12, 2010
I am using:
ASP.NET 3.5 SP1 with Web Forms Routing thru Global.asax (System.Web.Routing and RegisterRoutes)IIS 7
Everything is working fine in my local machine, but it gives the following error in my hosting environment:
Could not load file or assembly 'System.Web.Routing, Version=3.5.0.0, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I did everything inside my web.config file mentioned in the following link:
[URL]
But I am still getting the above error.
What else am I supposed to do fix the error?
View 1 Replies
Nov 19, 2010
i have the xml in a structure such as this:
<RWFCriteria reportType="ProgramReview">
<item id="36" name="" value="9" type="Milestone" />
<item id="31" name="" value="9" type="Milestone" />
<item id="33" name="" value="11" type="Milestone" />
</RWFCriteria>
View 1 Replies
Mar 22, 2010
I would like to transform an html input to xml. But the input will have as part of its content an "&", e.g. Texas A&M. But calling XslCompliledTransform.Transform(htmldocument, xmlwriter) causes an xmlexception to be thrown.
View 4 Replies
Aug 3, 2010
I need to programmatically parse and transform ASP.NET webform pages. It's a requirement that I have =(.
Anyone know any tools or frameworks?
Update:
I just need to modify ASPX pages (not rendered HTML code).
There are no inline c# code.
View 1 Replies
Oct 13, 2010
I want to use the web.config transformation that works fine for publish also for debugging.When i publish a web app, visual studio automatically transforms the web.config based on my currenc build configuration.How can i tell visual studio to do the same when i start debugging.On debug start it simply uses the default web.config without transformation.
View 5 Replies
Apr 16, 2010
I have easy to reproduce issue with web.config transform. Steps below are causing major grief.
Create new Web Application Project in VS 2010. Open web.debug.config, put following inside it
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform ="Replace">
<applicationSettings>
<MyProject.Properties.Settings>
<setting name="Username" serializeAs="String">
<value>username</value>
</setting>
</MyProject.Properties.Settings>
</applicationSettings>
</configuration>
Now deploy to file system on local hardrive. Open resulting web.config and see <value> setting has extrac carriag return and bunch of tabs in front of it..
Screenshots can be downloaded below.
[URL]
View 1 Replies
Jun 1, 2010
I've got a data table with columns in which include Item, Category and Value (and others, but those are the only relevant ones for this problem) that I access via LINQ in a C# ASP.Net MVC app. I want to transform these into a matrix and output that as a CSV file to pull into Excel as matrix with the items down the side, the categories across the top and the values in the row cells. However, I don't know how many, or what, categories there will be in this table, nor will there always be a record for each item/category combination.
I've written this by looping round, getting my "master category" list, then looking again for each item, filling in either blank or Value, depending on whether the item/category record exists, but as there are currently 27000 records in the table, this isn't as fast as I'd like. Is there a slicker and faster way I can do this, maybe via LINQ (firing into a quicker SQL statement so the DB server can do the leg-work), or will any method essentially come back to what I am doing?
View 2 Replies
Oct 27, 2010
What are the steps to execute the task above? the reason I want to do that now is because the web site is ready for deployment and
we would like to deliver it as a DLL. I've heard of [aspnet_merge.exe] but I want to ofuscate my code with a 3rd party tool; and this ofuscator tool only works with Project-based projects.
View 6 Replies
Feb 22, 2011
I have a Web application where i have added a reference to a RESTful WCF. I got the WCF url Routing to work in my webapplication by adding Inherits="RestService.Global" to the Web applications Global.asax.
<%@ Application Codebehind="Global.asax.cs" Inherits="RestService.Global" Language="C#" %>
But then i tried to create url Routing for the Web application and it does not work with the Inherits="RestService.Global" in the Global.asax. If i take it away it works fine. Is there a correct way to do this.
View 1 Replies
Jan 31, 2011
I'm trying to create my own CMS and I've gotten a little bit stuck at the stage of URL routing.
I want clean URLs without extensions and I'd like to be able to create and modify them in a web based interface without any messing around with IIS or actual files.
I've seen how to create a static route, but for that I need to go into my Global.asax file and manually add it.I would like to have all of these routes stored in a database so that I can easily modify them later.
Does anyone know how this can be achieved?
Just for extra information, I will be attempting to create a feature so that if a path exists, but is later changed, a 301 redirect is created to the new URL, is this also possible? (My first problem is the main issue, but thought I might ask this as well just in case it makes a difference)
View 2 Replies
Sep 2, 2010
How to handle asp.net mvc routing along with asp.net webform routing. I have merged my mvc app into my existing web application. In my web application i have implement routing as below:
routes.Add("View Product Details", new Route("Product/{City}/{Manufacturer}/{Name}/{ProductID}/{*ProductType}"));
Similarly i have implemented routing in mvc as below
routes.MapRoute("Product Details",
"Product/{City}/{Manufacturer}/{Name}/{ProductID}/{ProductType}",
new
{
controller = "Home",
action = "ProductDetails",
City= UrlParameter.Optional,
Manufacturer= UrlParameter.Optional,
Name= UrlParameter.Optional,
ProductID= UrlParameter.Optional,
ProductType= UrlParameter.Optional
});
How to handle both pages, as one is custom web form while other is asp.net mvc view?
View 1 Replies
Feb 10, 2011
I want to transfer data from datatable to a gridview with a hyperlink column. But dont know how to do.
I attach my code as below, what i want to do is to output 2 columns in gridview, and the first column should be a hyperlink. However, now the first column still shows nothing.
Web page code:
[Code]....
C# code:
[Code]....
View 6 Replies
Sep 22, 2014
I have a page with an panel on it that can contain a number of editable controls (textboxes, date pickers etc). This panel (and the controls) are populated dynamicaly by loading up an XSLT tranformation and applying it to an XML document (which represents the entity being edited) in the Pages Load event if !isPostBack.
Once the user has made changes they click a button and the form posts back. At that point I want to be able to go through the various controls in the panel, get the updated values and persist them back to a database. When I try to access the controls in the underlying buttons even theyre not there the panel is empty.
What I think is happening is that the page is being recreated at the start of the post back. When its recreated the XSLT transformation doesnt run because its a postback so the edit panel never gets repopulated. The controls therefore dont exist as far as my Button handler is concerned and it cant access their values.
My stopgap solution to this is that Im not checking isPostBack before repopulating the panel, so now the panel gets repopulated in the post back, the controls are there and Im able to query their values. The problem is that this involves another round trip to the database server to pick up the xslt and thats undesirable.So, first of all, have I understood the problem correctly?
I could save the trip to the db by storing the xslt (probably in the view state) but the whole idea of having to load up the control before checking its values feels sort of wrong and Im concerned that Im doing the wrong thing without realising. When I repopulate the control I am, of course, applying the XSLT to the XML document as it stood before the user made any edits. I would have expected querying the value of a control to return me the value before the user changes, but it actually seems to return me the value of the control as it was in the page when the user clicked the button. How can that be?
View 6 Replies
Feb 18, 2011
I have installed VS2010 ultimate and have read with interest about the new publish options, config transformations but none of them are available. I have tried creating different release versions and cannot see the option, also have no new options for publish, just look like the VS2008 ones.
Is there some service pack or pack that i need to install these or does it sound like a reinstall?
View 1 Replies
May 26, 2010
Does anyone know if there is a way to "transform" specific sections of values instead of replacing the whole value or an attribute?
For example, I've got several appSettings entries that specify the Urls for different webservices. These entries are slightly different in the dev environment than the production environment. Some are less trivial than others
[code]....
I've looked through the available web.config Transforms but nothings seems to be geared towars what I am trying to accomplish.
View 2 Replies
Nov 30, 2010
Response.RedirectPermanent(Url); can redirect permanently to a url.
However, during my SEO process, I decided to change my routhing rule.
For example,
I change "/tag/{tag}-quotes" routing rule to "quoes-about/{tag}", but I don't want to lose all the traffic to old routing url.
What is the best way to handle this permanent redirection?
View 4 Replies
Jul 10, 2010
I have asp.net web page that have the following :
<form id="WebCaptureForm" name="WebCaptureForm" onsubmit="return checkform(this);" enctype="multipart/form-data" method=post
action="http://site/page.aspx?idn=1&tr=100d1165&action=savenew">
I want to make new page with master page that contain the same code but how can i make the above code in a web page that have a master page
View 1 Replies
Aug 27, 2010
I have a question:
When I want to add "<br>" to a text of a gridview row to make it starts in a new line, but it doesn't work and I got the "<br>" in the view source of the IE.
View 2 Replies