c# - Escape fullstop before slash in URL string -
i've found oddity i'm trying around c# sanitizing / interfering specified url, , giving 404 result.
it happens there's forward slash after full-stop - c# , visual studio determined remove fullstop.
for visual studio, control-click string linking mal-formed url
in compiled c# string transformed, before getting new uri().
the link is:
http://www.mattmulholland.co.nz/matt_mulholland/matt_mulholland_-_official_website._boom./rss.xml
(it's './' @ end causes issue)
i've tried escaping both fullstop + slash in ascii, , 'dontescape' option in uri() constructor, no luck far...
and other thoughts how can string allow correct url?
thanks.
this use:
// call line once in application lifetime (when app starts) applyfixenddoturl(); // -------------------------- uri testurl = new uri("http://www.mattmulholland.co.nz/matt_mulholland/matt_mulholland_-_official_website._boom./rss.xml"); string strurl = testurl.tostring(); // -------------------------- // -> using system.reflection; public static void applyfixenddoturl() { methodinfo getsyntax = typeof(uriparser).getmethod("getsyntax", system.reflection.bindingflags.static | system.reflection.bindingflags.nonpublic); fieldinfo flagsfield = typeof(uriparser).getfield("m_flags", system.reflection.bindingflags.instance | system.reflection.bindingflags.nonpublic); if (getsyntax != null && flagsfield != null) { foreach (string scheme in new[] { "http", "https" }) { uriparser parser = (uriparser)getsyntax.invoke(null, new object[] { scheme }); if (parser != null) { int flagsvalue = (int)flagsfield.getvalue(parser); if ((flagsvalue & 0x1000000) != 0) flagsfield.setvalue(parser, flagsvalue & ~0x1000000); } } } } this solution found here: httpwebrequest url dot @ end (.net 2.0 framework)
Comments
Post a Comment