as far as referencing your URLs.
When you use Response.Redirect, do you use
1) Hard-coded string -- Response.Redirect("MyPage.aspx");
2) Constants -- Response.Redirect(STRMyPage); // where input parameter
is -> const string STRMyPage = "MyPage.aspx";
3) Something entirely differnent?
If you use constants do you keep them in one class as static public members,
e.g. MyUrlConstants.cs, then MyUrlConstans.STRMyPage.
Thanks,
AmelyanTypically, you wouldn't be changing the page filename (especially if you
want it indexed by the search engines). So why bother creating constants?
The page filename wouldn't change so it is, in affect, a constant already.
--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx
"Amelyan" <bamelyan@.wi.rr.com> wrote in message
news:%23gNR%23umTFHA.3152@.TK2MSFTNGP12.phx.gbl...
>I am struggling here trying to determine what is a good programming
>practice as far as referencing your URLs.
> When you use Response.Redirect, do you use
> 1) Hard-coded string -- Response.Redirect("MyPage.aspx");
> 2) Constants -- Response.Redirect(STRMyPage); // where input parameter
> is -> const string STRMyPage = "MyPage.aspx";
> 3) Something entirely differnent?
> If you use constants do you keep them in one class as static public
> members, e.g. MyUrlConstants.cs, then MyUrlConstans.STRMyPage.
> Thanks,
> Amelyan
I can't disagree more. While you might not change filenames every day, I
think we've all lived through one exercise or another (redevelopment,
application merge, application split, ...) which has required this type of
work. It takes such little effor to build a flexible navigation model, I'm
not sure why you'd ever hard-code values. ASP.Net 2.0's built-in navigation
features should be proof positive that this is an important feature.
As such, what I would suggest would be to follow the SiteUrls example from
the CommuityServer project. Basically, you have a class which parses an xml
file..and exposes the results..There specific implementation is likely a
little more complicated than necessary, but I'd certainly go about something
similar.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Robbe Morris [C# MVP]" <info@.turnkeytools.com> wrote in message
news:e45d1TnTFHA.612@.TK2MSFTNGP12.phx.gbl...
> Typically, you wouldn't be changing the page filename (especially if you
> want it indexed by the search engines). So why bother creating constants?
> The page filename wouldn't change so it is, in affect, a constant already.
> --
> 2005 Microsoft MVP C#
> Robbe Morris
> http://www.robbemorris.com
> http://www.masterado.net/home/listings.aspx
>
> "Amelyan" <bamelyan@.wi.rr.com> wrote in message
> news:%23gNR%23umTFHA.3152@.TK2MSFTNGP12.phx.gbl...
>>I am struggling here trying to determine what is a good programming
>>practice as far as referencing your URLs.
>>
>> When you use Response.Redirect, do you use
>>
>> 1) Hard-coded string -- Response.Redirect("MyPage.aspx");
>> 2) Constants -- Response.Redirect(STRMyPage); // where input parameter
>> is -> const string STRMyPage = "MyPage.aspx";
>> 3) Something entirely differnent?
>>
>> If you use constants do you keep them in one class as static public
>> members, e.g. MyUrlConstants.cs, then MyUrlConstans.STRMyPage.
>>
>> Thanks,
>> Amelyan
>>
Karl's rationale is correct but he does not suggest an implementation
methodology. The easiest implementation will get the name of the page from
the server variables collection and using that value to populate a local
variable which is passed through the parameter of the redirect method of the
response object.
There is also much to be said about when to use the server.transfer method
instead of the response.redirect but I leave that for further study.
Finally, conforming with canonical form would require writing the variable
name as strMyPage rather than STRMyPage but I suggest it would clarify the
code to simplify and use strPageName when using this particular form of
notation.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Op492unTFHA.2812@.TK2MSFTNGP09.phx.gbl...
>I can't disagree more. While you might not change filenames every day, I
>think we've all lived through one exercise or another (redevelopment,
>application merge, application split, ...) which has required this type of
>work. It takes such little effor to build a flexible navigation model, I'm
>not sure why you'd ever hard-code values. ASP.Net 2.0's built-in
>navigation features should be proof positive that this is an important
>feature.
> As such, what I would suggest would be to follow the SiteUrls example from
> the CommuityServer project. Basically, you have a class which parses an
> xml file..and exposes the results..There specific implementation is likely
> a little more complicated than necessary, but I'd certainly go about
> something similar.
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
>
> "Robbe Morris [C# MVP]" <info@.turnkeytools.com> wrote in message
> news:e45d1TnTFHA.612@.TK2MSFTNGP12.phx.gbl...
>> Typically, you wouldn't be changing the page filename (especially if you
>> want it indexed by the search engines). So why bother creating
>> constants?
>> The page filename wouldn't change so it is, in affect, a constant
>> already.
>>
>> --
>> 2005 Microsoft MVP C#
>> Robbe Morris
>> http://www.robbemorris.com
>> http://www.masterado.net/home/listings.aspx
>>
>>
>>
>> "Amelyan" <bamelyan@.wi.rr.com> wrote in message
>> news:%23gNR%23umTFHA.3152@.TK2MSFTNGP12.phx.gbl...
>>>I am struggling here trying to determine what is a good programming
>>>practice as far as referencing your URLs.
>>>
>>> When you use Response.Redirect, do you use
>>>
>>> 1) Hard-coded string -- Response.Redirect("MyPage.aspx");
>>> 2) Constants -- Response.Redirect(STRMyPage); // where input parameter
>>> is -> const string STRMyPage = "MyPage.aspx";
>>> 3) Something entirely differnent?
>>>
>>> If you use constants do you keep them in one class as static public
>>> members, e.g. MyUrlConstants.cs, then MyUrlConstans.STRMyPage.
>>>
>>> Thanks,
>>> Amelyan
>>>
>>
>>
Rob Morris mentioned "you wouldn't be changing the page filename especially
if you want it indexed by the search engines." I think this is a very
strong point. Does anyone disagree with that?
"clintonG" <csgallagher@.REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:epjoknsTFHA.3308@.TK2MSFTNGP14.phx.gbl...
> Karl's rationale is correct but he does not suggest an implementation
> methodology. The easiest implementation will get the name of the page from
> the server variables collection and using that value to populate a local
> variable which is passed through the parameter of the redirect method of
> the response object.
> There is also much to be said about when to use the server.transfer
> method instead of the response.redirect but I leave that for further
> study.
> Finally, conforming with canonical form would require writing the variable
> name as strMyPage rather than STRMyPage but I suggest it would clarify the
> code to simplify and use strPageName when using this particular form of
> notation.
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
>
> "Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:Op492unTFHA.2812@.TK2MSFTNGP09.phx.gbl...
>>I can't disagree more. While you might not change filenames every day, I
>>think we've all lived through one exercise or another (redevelopment,
>>application merge, application split, ...) which has required this type of
>>work. It takes such little effor to build a flexible navigation model,
>>I'm not sure why you'd ever hard-code values. ASP.Net 2.0's built-in
>>navigation features should be proof positive that this is an important
>>feature.
>>
>> As such, what I would suggest would be to follow the SiteUrls example
>> from the CommuityServer project. Basically, you have a class which
>> parses an xml file..and exposes the results..There specific
>> implementation is likely a little more complicated than necessary, but
>> I'd certainly go about something similar.
>>
>> Karl
>>
>>
>>
>> --
>> MY ASP.Net tutorials
>> http://www.openmymind.net/ - New and Improved (yes, the popup is
>> annoying)
>> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
>> come!)
>>
>>
>> "Robbe Morris [C# MVP]" <info@.turnkeytools.com> wrote in message
>> news:e45d1TnTFHA.612@.TK2MSFTNGP12.phx.gbl...
>>> Typically, you wouldn't be changing the page filename (especially if you
>>> want it indexed by the search engines). So why bother creating
>>> constants?
>>> The page filename wouldn't change so it is, in affect, a constant
>>> already.
>>>
>>> --
>>> 2005 Microsoft MVP C#
>>> Robbe Morris
>>> http://www.robbemorris.com
>>> http://www.masterado.net/home/listings.aspx
>>>
>>>
>>>
>>> "Amelyan" <bamelyan@.wi.rr.com> wrote in message
>>> news:%23gNR%23umTFHA.3152@.TK2MSFTNGP12.phx.gbl...
>>>>I am struggling here trying to determine what is a good programming
>>>>practice as far as referencing your URLs.
>>>>
>>>> When you use Response.Redirect, do you use
>>>>
>>>> 1) Hard-coded string -- Response.Redirect("MyPage.aspx");
>>>> 2) Constants -- Response.Redirect(STRMyPage); // where input parameter
>>>> is -> const string STRMyPage = "MyPage.aspx";
>>>> 3) Something entirely differnent?
>>>>
>>>> If you use constants do you keep them in one class as static public
>>>> members, e.g. MyUrlConstants.cs, then MyUrlConstans.STRMyPage.
>>>>
>>>> Thanks,
>>>> Amelyan
>>>>
>>>
>>>
>>
>>
Sometimes you have to change the path. Sometimes you don't care about
search engines, or you control it (ie, on intranets for example). The point
is, sometimes you have to change it..so you change it! You might use
Redirects to keep existing search results happy...or url rewriting...
That isn't to say you should avoid it unless required to, I think what
Clinton and I think is that sometimes you don't have a choice and building
the flexibility upfront has a little cost for a huge gain.
Karl
P.S. - I did make a suggestions of sorts..that was to emualte what
CommunityServer did with XML files and SiteUrls...granted I could have been
more descriptive...
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Amelyan" <bamelyan@.wi.rr.com> wrote in message
news:OSw4zJyTFHA.2664@.TK2MSFTNGP15.phx.gbl...
> Rob Morris mentioned "you wouldn't be changing the page filename
> especially if you want it indexed by the search engines." I think this is
> a very strong point. Does anyone disagree with that?
>
> "clintonG" <csgallagher@.REMOVETHISTEXTmetromilwaukee.com> wrote in message
> news:epjoknsTFHA.3308@.TK2MSFTNGP14.phx.gbl...
>> Karl's rationale is correct but he does not suggest an implementation
>> methodology. The easiest implementation will get the name of the page
>> from the server variables collection and using that value to populate a
>> local variable which is passed through the parameter of the redirect
>> method of the response object.
>>
>> There is also much to be said about when to use the server.transfer
>> method instead of the response.redirect but I leave that for further
>> study.
>>
>> Finally, conforming with canonical form would require writing the
>> variable name as strMyPage rather than STRMyPage but I suggest it would
>> clarify the code to simplify and use strPageName when using this
>> particular form of notation.
>>
>> <%= Clinton Gallagher
>> METROmilwaukee (sm) "A Regional Information Service"
>> NET csgallagher AT metromilwaukee.com
>> URL http://metromilwaukee.com/
>> URL http://clintongallagher.metromilwaukee.com/
>>
>>
>>
>>
>>
>> "Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
>> wrote in message news:Op492unTFHA.2812@.TK2MSFTNGP09.phx.gbl...
>>>I can't disagree more. While you might not change filenames every day, I
>>>think we've all lived through one exercise or another (redevelopment,
>>>application merge, application split, ...) which has required this type
>>>of work. It takes such little effor to build a flexible navigation
>>>model, I'm not sure why you'd ever hard-code values. ASP.Net 2.0's
>>>built-in navigation features should be proof positive that this is an
>>>important feature.
>>>
>>> As such, what I would suggest would be to follow the SiteUrls example
>>> from the CommuityServer project. Basically, you have a class which
>>> parses an xml file..and exposes the results..There specific
>>> implementation is likely a little more complicated than necessary, but
>>> I'd certainly go about something similar.
>>>
>>> Karl
>>>
>>>
>>>
>>> --
>>> MY ASP.Net tutorials
>>> http://www.openmymind.net/ - New and Improved (yes, the popup is
>>> annoying)
>>> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
>>> come!)
>>>
>>>
>>> "Robbe Morris [C# MVP]" <info@.turnkeytools.com> wrote in message
>>> news:e45d1TnTFHA.612@.TK2MSFTNGP12.phx.gbl...
>>>> Typically, you wouldn't be changing the page filename (especially if
>>>> you
>>>> want it indexed by the search engines). So why bother creating
>>>> constants?
>>>> The page filename wouldn't change so it is, in affect, a constant
>>>> already.
>>>>
>>>> --
>>>> 2005 Microsoft MVP C#
>>>> Robbe Morris
>>>> http://www.robbemorris.com
>>>> http://www.masterado.net/home/listings.aspx
>>>>
>>>>
>>>>
>>>> "Amelyan" <bamelyan@.wi.rr.com> wrote in message
>>>> news:%23gNR%23umTFHA.3152@.TK2MSFTNGP12.phx.gbl...
>>>>>I am struggling here trying to determine what is a good programming
>>>>>practice as far as referencing your URLs.
>>>>>
>>>>> When you use Response.Redirect, do you use
>>>>>
>>>>> 1) Hard-coded string -- Response.Redirect("MyPage.aspx");
>>>>> 2) Constants -- Response.Redirect(STRMyPage); // where input
>>>>> parameter is -> const string STRMyPage = "MyPage.aspx";
>>>>> 3) Something entirely differnent?
>>>>>
>>>>> If you use constants do you keep them in one class as static public
>>>>> members, e.g. MyUrlConstants.cs, then MyUrlConstans.STRMyPage.
>>>>>
>>>>> Thanks,
>>>>> Amelyan
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
0 comments:
Post a Comment