Configuration :: URL Rewrite Module With Database Call?
Feb 25, 2011
Hello, I'm trying to implement URL rewriting for the first time. I must use URL Rewrite Module IIS7 per my hosting company. All of the examples I have found so far will rewrite a url such as:
www.domain.com/ShowProduct.aspx?ID=233&Title=Product-Title,
to: www.domain.com/ShowProduct/ProductTitle/233. The common scenario between these examples is that the rewrite chops off the .aspx & special characters and shuffles the query string parameters around. I get how that all works. However, I had something a little different in mind and I'm not sure if it can be accomplished.
My urls currently look like this: www.domain.com/ShowProduct?ID=233, and I would like them to look like this: www.domain.com/ShowProduct/Product-Title. The way I would imagine this working is, during the rewrite, pass the ID to the db and return the Title for the new url. You see, I currently don't need to pass the Title as a query string parameter and I'd prefer to not show the ID at all. This would be ideal. Can this be accomplished? Or
will I have to add the Title as a query string param and show the ID in rewritten url?
View 2 Replies
Similar Messages:
Jan 18, 2010
I have the following setting in my web.config to redirect to a default page:
<defaultDocument>
<files>
<clear/>
<add value="default.aspx"/>
</files>
</defaultDocument>
For example when a user enters www.homeforhire.com they should be redirected to default.aspx (for operational reasons the user is then redirected to
www.homeforhire.com/home.aspx).
Instead an error is caught in the Rewrite module (which should not be activated). I am using an http module to perform URL rewriting.
It appears as if the default document setup is not working correctly, and the requested page ~/ is being sent to the Rewrite module, causing an error (which is then caught by my error handler and the user is redirected to the home page).
Entering www.homeforhire.com/default.aspx works correctly.
Can anyone tell me why the default document settings in the web.config do not appear to be working?
View 1 Replies
Jan 26, 2010
I use IIS 7 URL Rewrite Module and it works fine.
But My javascript code doesn't work anymore on the page (details.aspx) where i use URL Rewrite Module.
Example :
<a href="#" target="popup" onclick="wopen('note.aspx?ID=<%#CType(FormView1.DataItem, System.Data.DataRowView).Item("NoteID")%>&S=<%#CType(FormView1.DataItem, System.Data.DataRowView).Item("IsS")%>','popup',480,480); return false;">
Write a note</a>
If i disable the rule in IIS, this link works as expected.
The Rewrite rule doesn't include the note.aspx page.
View 8 Replies
Sep 21, 2010
I'm probably going to use the URL rewrite module for IIS 7 eventually and I have a fairly straight forward question that I really can't find the answer to.
If you have a base case of:
http://yoururl.com/page.aspx?ID=7
You can obviously have it rewritten to:
http://yoururl.com/page/7 or whatever you want.
My question is this: When using this module can you still use Request.Querystring["page"] on the rewritten querystring. How does the Request.URL stuff work. Does asp.net still provide the un-rewritten url or does it provide the rewritten one.
I would assume that your C#/asp.net code is completely unaffected by the url rewriting, as that's more or less the point, but I want to be crystal clear.
Secondary question: What is the best practice for how you should code a website when using the rewritten. Should you code links in the written style, or continue using querystrings?
View 1 Replies
Apr 9, 2010
I would like to use the Helicon ISAPI_REWRITE module to rewrite a url:
123.45.67.89/folder
to
www.site.com
I need to mask the IP/folder due to an IIS structure change. The reason why I don't want to get into, but it's valid based on the setup.
View 1 Replies
Jun 11, 2010
The IIS URL Rewrite Module ships with 3 built-in functions:
* ToLower - returns the input string converted to lower case.
* UrlEncode - returns the input string converted to URL-encoded format. This function can be used if the substitution URL in rewrite rule contains special characters (for example non-ASCII or URI-unsafe characters).
* UrlDecode - decodes the URL-encoded input string. This function can be used to decode a condition input before matching it against a pattern.
The functions can be invoked by using the following syntax:
{function_name:any_string}
The question is: can this list be extended by introducing a Replace function that's available for changing values within a rewrite rule action or condition?
Another way to frame the question: is there any way to do a global replace on a URL coming in using this module?
It seems that you're limited to using regular expressions and back-references to construct strings - i.e. there's no search/replace mechanism to replace every instance of X with Y in {REQUEST_URI}, without knowing how many instances there are.
I've had a quick glance at the extensibility introduced in the 2.0 RTW and don't see any 'light' means of introducing this.
View 1 Replies
Feb 19, 2010
Is it possible to use iis7 url rewrite module for html pages?
Like this:
http://www.site.com/index.html?x=newfolder =>
http://www.site.com/newfolder
View 2 Replies
Feb 2, 2011
I have a website hosted on IIS7 with the url rewrite module 2.0 installed. It is run by content management that looks at the url and returns a 401 error if the current user does not have permission to view the page. This gets picked up by the asp.net url authorization module which then kicks the page over to the loginUrl page as specified in the web.config (forms authentication).
This works perfectly on my local machine - which is IIS7 and windows7.
If the url is, say, /612/some-string the user gets directed to the login page at /66/login?ReturnUrl=/612/some-string
The url rewriting looks at the first part of the url for the document id. The real url would be this: index.aspx?documentId=612
Unfortunately, when I deployed this to our staging server, the ReturnUrl isn't the rewritten url, it's the original url. This causes all sorts of problems.
The staging server is also IIS7 with the url rewrite module 2.0 installed. It's Windows 2008 server SP2. Both are running asp.net 3.5.
My only guess is that the machine.config orders the default httpModules differently, and the .net forms authentication module is jumping in before the url has been rewritten.
I'll review that soon, but in the meantime has anyone experienced this problem and solved it?
Update
I also tried changing
Response.StatusCode = 401;
to
FormsAuthentication.RedirectToLoginPage();
Which gets me a bit ahead, but still directs the user back to the url that hasn't been rewritten.
I can also do this instead of setting the 401:
string currentPage = HttpUtility.UrlEncode(Request.RawUrl);
string loginUrl = FormsAuthentication.LoginUrl + "?ReturnUrl=" + currentPage;
Response.Redirect(loginUrl);
But this seems ugly.
View 1 Replies
Jan 12, 2011
In our ASP.NET web application, we use our own class to act as a rewrite module. It takes all requests to the server, acting as a bootstrapper.
To access an image on our web application, the browser requests domain.com/ResourceItem.aspx?Id=74
Does not having a proper URI mean the server will never respond with 304 NOT MODIFIED?
how to get the 304 response, so the browser doesn't have to download each image every refresh?
View 2 Replies
May 6, 2010
I have web services built with ASP.NET and ASP.NET clients consuming them. When consuming the webservices, how would I to force the clients to use https?
I don't want to force the whole site to use https by turning on require SSL in IIS.
Can I use the IIS7 URL rewrite module to re-route http requests to https?
View 2 Replies
Feb 16, 2011
I need to force every request to https://www.mysite.com (always with https and www)
The site is hosted in GoDaddy and I need to do it via IIS7 URL Rewrite Module.
I've been able to do the HTTPS redirect with the following code:
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical Host Name" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^mysite.com$" />
</conditions>
<action type="Redirect" url="https://www.mysite.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
Test cases
http://mysite.com -> https://www.mysite.com OK
http://www.mysite.com -> https://www.mysite.com NOT WORKING
I guess the condition is not being satisfied when I enter www.mysite.com in the browser, so there's no redirect and the page serves as HTTP instead of HTTPS.
I think I just need to modify the condition pattern, but I have almost nothing regex knowledge and I need this asap.
View 1 Replies
Oct 3, 2010
I am trying to rewrite url in IIS server.What would be the simplest steps for getting this functionalities in my website.
View 1 Replies
Oct 13, 2010
Rewrite has been working like a charm when testing and using it locally. However when I uploaded my application, then it gave me some problems.Problem Overview
My site - http://www.site.com/
Site is stored in a subdirectory on my root hosting in a folder call "sub".
So when I go to the URL http://www.site.com/part1/file.aspx then in my Rewrite Rule the {URL} is given as "/sub/part1/file.aspx" instead of "/part1/file.aspx"
Problem/Question,Is there a way I can handle all the {URL} in my Rewrite Rules without including the "sub" in the {URL} and without having to change every single ones Pattern?
View 1 Replies
Feb 24, 2011
I can't for the life in me work out how to get the outbound rules to work. All my inbound are spot on (not included). I have dynamic and statis compression disabled, I moved the module up in the modules list just incase.The server is Windows 2008 R2 x64 if that makes a difference. Also not that the 'Content' pages get rewritten perfectly. I don't get it.
You can view the live site here: http://www.ink4u.co.uk
[Code]....
View 1 Replies
Oct 4, 2010
I am trying to make a rewrite rule to check whether the URLends with '.htm' or '.html', but does not contain 'Archive.aspx'. How can I do this with regular expression?
The url starts out like this: [URL]/test.htm(or .html), and ends up like this:[URL]
View 2 Replies
Nov 20, 2010
I am using a project that rewrites URL. I am not familiar with this code, but it works fine on IIS 6 and with VS2010. Problem begins when I need to deploy into IIS7.5 server. Seems like the rewrite doesn't work and the page doesn't fount after rewriting page.
[Code]....
I am trying to use this web.config code, but then I could see this:
[Code]....
View 1 Replies
Mar 17, 2010
i am using microsoft visual studio 2008 sp1 for developing my web sitei have done url rewrite with this way and it does work on host perfectly
[Code]....
but it does not working on remote hostmy remote host is windows server 2008 sp1 and iss7do i need to make any setting on remote host to make it work ?
View 6 Replies
May 7, 2015
See below code "ViewEntry.aspx" in web config file i am using to display post of my blog in the same way i want to use one more page to display categories of my blog.
How to use multiple url in web config file inside the rewriter tag?
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
<rewriter>
<rewrite url="(.+)-(.+).aspx" to="~/ViewEntry.aspx?id=$2"/>
[Code] ....
View 1 Replies
Oct 14, 2010
I'm trying to implement URL Rewriting into my existing application and have managed to get the page and links working except that my destination page does not get the query string values.Mycde is based on the example below: http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.htmlBasically I have a default.aspx page with links to another page; directory_item.aspx?Item_Id=1&Category_Id=1 directory_item.aspx?Item_Id=2&Category_Id=1 and so on... The code in my web config is as follows;
[Code]...
View 3 Replies
Jan 4, 2011
I need to use a function located in a delphi dll (no com, unmanaged etc).
My first approach was to place the dll in the BIN folder and use the following:
[Code]....
This returns the error. I have been experimenting with placing the dll differently and using the full path in the DllImport part, but with no luck.
View 1 Replies
Feb 3, 2011
If application is started without debugging - it runs smoothly, when I press F5 I get: "Unable to start debugging on the web server. Could not start ASP.NET debugging. More information may be available by starting the project without debugging. Click Help for more information"I noticed that problems are caused by URL Rewrite section in web.config:
<rewrite>
<rules>
<clear />
<rule name="LowerCaseRule" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
when I comment it out - I can start debugging. Also debugging works on VS's built-in web server.I'm running Win7 64 bit, VS 2010, application's framework is 4.0, in IIS application has ASP.NET 4.0 Intergrated pool set
View 2 Replies
Feb 15, 2011
i am making an application which is like chain system..i mean one person can have multiple child.. then his child can have multiple child ..etc like chain system...i dont know to insert into database.. so that when i call any-node.. his child,, and their futher child will show...
View 14 Replies
Feb 10, 2010
I am in the process of redesigning our main product, a knowledge database system for clients to access clinical and specialist advice articles. There is a requirement to add "Social Networking" to this allowing users to connect and post remarks etc...
This is somewhat similar to the Facebook wall scenario - where Articles, Photos, Groups, Products, Events, ActivityFeed can all have comments. I am at a lose as to the database design I would need to implement this. All comments must allow for Moderation/Approval/Spam Reporting etc...
I originally thought a individual table for each Comments entity ex: ArticleComment, ProductComment would work as the comments themselves are not all directly related. Each table having the same exact columns. But this makes life abit awkward as then this creates a separation between something that for all purposes is the same i.e. They are all comments.
The other design idea was to have a single Comment table with an "arc" type relationship to related tables with FK references back to the source.
The other option was to have a single Comment table with an Object Type and XID but this breaks the rules of relation and does not all for referential integrity.
I am at a lose and don't know what to do. I have asked over at SQLCentral.com and all I have done is raised more questions than answers about what to do.
Design 1: This would require exact copies of this table for all the entities.
-- Photo Comments --
CREATE TABLE dbo.PhotoComment
(
CommentID int IDENTITY(1,1) NOT NULL,
PhotoID int NOT NULL,
Body ntext NOT NULL,
ReportedAsSpam bit NOT NULL CONSTRAINT [DF_PhotoComment_ReportedAsSpam] DEFAULT (0),
IsSpam bit NOT NULL CONSTRAINT [DF_PhotoComment_IsSpam] DEFAULT (0),
IsApproved bit NOT NULL CONSTRAINT [DF_PhotoComment_IsApproved] DEFAULT (1),
CreatedDate datetime NOT NULL,
CreatedBy uniqueidentifier NOT NULL,
UpdatedDate datetime NOT NULL,
UpdatedBy uniqueidentifier NOT NULL,
IsDeleted bit NOT NULL CONSTRAINT [DF_PhotoComment_IsDeleted] DEFAULT (0),
CONSTRAINT [PK_PhotoComment] PRIMARY KEY (CommentID),
CONSTRAINT [FK_PhotoComment_PhotoID] FOREIGN KEY (PhotoID) REFERENCES dbo.Photo(PhotoID),
CONSTRAINT [FK_PhotoComment_CreatedBy] FOREIGN KEY (CreatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [FK_PhotoComment_UpdatedBy] FOREIGN KEY (UpdatedBy) REFERENCES dbo.aspnet_Users(UserId)
)
Design 2: The "Arc" relationship
CREATE TABLE dbo.Comment
(
CommentID int IDENTITY(1,1) NOT NULL,
CommentType char(1) NOT NULL CHECK(CommentType IN ('A','I','E','G','U','P')),
Body ntext NOT NULL,
ReportedAsSpam bit NOT NULL CONSTRAINT [DF_Comment_ReportedAsSpam] DEFAULT (0),
IsSpam bit NOT NULL CONSTRAINT [DF_Comment_IsSpam] DEFAULT (0),
IsApproved bit NOT NULL CONSTRAINT [DF_Comment_IsApproved] DEFAULT (1),
CreatedDate datetime NOT NULL,
CreatedBy uniqueidentifier NOT NULL,
UpdatedDate datetime NOT NULL,
UpdatedBy uniqueidentifier NOT NULL,
IsDeleted bit NOT NULL CONSTRAINT [DF_Comment_IsDeleted] DEFAULT (0),
CONSTRAINT [PK_Comment] PRIMARY KEY (CommentID),
CONSTRAINT [FK_Comment_CreatedBy] FOREIGN KEY (CreatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [FK_Comment_UpdatedBy] FOREIGN KEY (UpdatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [UC_Comment_CommentID_CommentType] UNIQUE (CommentID, CommentType)
)
-- Article Comments --
CREATE TABLE dbo.ArticleComment
(
ArticleID int NOT NULL,
CommentID int NOT NULL,
CommentType char(1) CONSTRAINT [DF_ArticleComment_CommentType] DEFAULT 'A', CHECK (CommentType = 'A'),
CONSTRAINT [PK_ArticleComment] PRIMARY KEY CLUSTERED (ArticleID, CommentID),
CONSTRAINT [FK_ArticleComment_ArticleID] FOREIGN KEY (ArticleID) REFERENCES dbo.Article(ArticleID),
CONSTRAINT [FK_ArticleComment_CommentID] FOREIGN KEY (CommentID) REFERENCES dbo.Comment(CommentID),
CONSTRAINT [FK_ArticleComment_CommentID_CommentType] FOREIGN KEY (CommentID, CommentType) REFERENCES dbo.Comment(CommentID, CommentType)
)
Design 3: The one that breaks the rules
CREATE TABLE dbo.Comment
(
CommentID int IDENTITY(1,1) NOT NULL,
ObjectType char(1) NOT NULL, /* A = Article, P = Photo etc... */
XID int NOT NULL, /* Would be the ID of the main entity being queried. */
Body ntext NOT NULL,
ReportedAsSpam bit NOT NULL CONSTRAINT [DF_Comment_ReportedAsSpam] DEFAULT (0),
IsSpam bit NOT NULL CONSTRAINT [DF_Comment_IsSpam] DEFAULT (0),
IsApproved bit NOT NULL CONSTRAINT [DF_Comment_IsApproved] DEFAULT (1),
CreatedDate datetime NOT NULL,
CreatedBy uniqueidentifier NOT NULL,
UpdatedDate datetime NOT NULL,
UpdatedBy uniqueidentifier NOT NULL,
IsDeleted bit NOT NULL CONSTRAINT [DF_Comment_IsDeleted] DEFAULT (0),
CONSTRAINT [PK_Comment] PRIMARY KEY (CommentID),
CONSTRAINT [FK_Comment_CreatedBy] FOREIGN KEY (CreatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [FK_Comment_UpdatedBy] FOREIGN KEY (UpdatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [UC_Comment_CommentID_ObjectType_XID] UNIQUE (CommentID, ObjectType, XID)
)
-- Ex: Get all comments for article ID 23.
SELECT * FROM Comment Where ObjectType ='A' and XID = '23'
View 1 Replies
Aug 3, 2010
I have several web sequential pages which will modify a record and its child records in the database, called a "project". Such a project is currently passed between pages using its database ID in the URL parameters.
A project has some information specific to itself, and also consists of one or more Tasks, which each have information specific to itself.
Is it faster (alternatively, more maintainable or more easily understood) to hit the database each time I need to query the same project (and its tasks), or should I query the database once (either once for each page or once for all pages and save to Session) and check the saved object rather than the database?
View 2 Replies
May 2, 2010
I have an ms access db file and now i want to use it in my app. i have given like
Provider=MSDASQL.1;Password=pwd123;Persist Security Info=True;User ID=swgp;Data Source=SWGP;Initial Catalog=C:swgp BJswgp
but it is giving error to me.If anybody know how to give this connection string for password enabled ms access database,
View 2 Replies