Is it possible to redirect a link that ends with .aspx to a .ashx? - xml-serialization

We have a website that we recently released based mostly on SharePoint. Some of the site needed to return just straight XML. The consultants on the project implemented the xml returns as .aspx pages that write the response object in the page_load method.
After a short time researching this, I relize that this is probably the wrong way to do this because it calls all the extra events for a ASPX page that we don't need.
Here's my question, I want to recreate these functions as .ashx links with the httphandler. However, I want to be able to retain the orginal links that ended in .aspx and the get parameters that accompany them to decide which type of XML to return.
Is is possible to rewrite/redirect the .aspx ending links to a .ashx link. Or would that cause the IIS server to interpret every .aspx incorrectly?

I think you're probably in luck...
We did a similar thing. Our eCommerce web app only accepts JPG, PNG and GIF files as the images for products, but we wanted every image to be dynamically created for every product.
So, we remapped JPG, PNG and GIF files to become a handler.
However, we didn't want ALL JPG, PNG and GIF files to be mapped since it would be hugely inefficient for static files, so we only did certain ones.
Here is how to do it.
If all of your ASPX files follow a similar file-spec that NO other files share, add this to your web.config under <httpHandlers>.
<add path="filespec*.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
If they don't all share a file-spec, you'll have to add them one-by-one to web.config:
<add path="oldaspx1.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
<add path="oldaspx2*.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
<add path="oldaspx3*.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
To make this usuable whether or not you are running in the IIS7 integrated pipeline, you could also add similar lines to the <handlers> element
Then when a request comes in for 'oldaspx1.aspx', it will get handled (very efficiently, without the page lifecycle being started) by your custom handler.
If this solves your problem, please mark it as the accepted answer with the check mark to the left.

Related

Programmactly change in your web.config in releasemode

I have been roaming around the internet to figure out what the best solution to my issue would be, but I cant seem to find a satisfying answer.
My problem is, that I wish an administrator of my website to be able to change a server-setting (email, password and Exchange server endpoint url) - this should be possible to do in the browser, so the admin doesnt have to open up the web.config file.
The settings are rarely set, but the possibility for it HAS to be present.
What I do now, is that once the admin fills out my form, my controller will set the new values in the web.config AppSettings:
<appSettings>
<add key="ewsUser" value="some#thing.com" />
<add key="ewsPW" value="somePW" />
<add key="ewsUrl" value="https://outlook.ews.com/xxx.asmx" />
</appSettings>
This is where my big concern begins, because of all my research through out the internet.
Lets say my application now is online, and is being used by hundreds of people 24/7, would this solution then be an issue?
I have read that if you make changes to your web.config file it will make your application restart on the server, without throwing off any clients. But will this affect the session the clients are in right in that moment? Will the server forget their sessions?
I've read a bit on bad practices, and this article states how it could be solved by making a new .config file and link to that config file in the web.config AppSettings. But is this really necessary? I find it a bit more messy than my current solution.
Any ideas, thoughts and/or facts would be appriciated.
Writing to a web.config is indeed a bad practice. When changing a web.config file your application will restart. Not sure about the sessions though but they will probably reset. And what about the situation where you deploy a new version of your application and accidentally overwrite the web.config?
Two solutions that might be helpful:
Create a simple key/value table in a database
Create your custom XML format and write/read to a file (and name the file for example mysettings.config instead of mysettings.xml to prevent direct access from a webbrowser)
To speed-up things you could cache these values in memory after reading.

Charts not showing on Crystal Reports Viewer in WebForm

After days of struggling, I finally have the viewer showing the images on it's icons and buttons, and showing the report nicely. However, as soon as it comes to a chart, all it it shows is a border and that little icon that shows there is supposed to be an image. Inspecting the image URL and trying to show that image in its own tab yields as little success.
What could I look at or do to get my charts showing properly?
Found this response on SAP's forum, related to a similar-sounding issue:
Since your dynamic images are okay it is likely the sscsdk80.dll (our
charting engine) which is the problem. You'll find this in the bin or
win32_x86 directory with the rest of your Crystal Reports dlls. It
needs to be registered with regsvr32.dll because it is a COM dll. Try
registering it to see if it helps.
If not, use Process Monitor to watch your system. Filter the results
for your application (likely w3wp.exe because it is a web app). Then
show only the results for Process and Thread activity. You'll want to
look at the Load Image entries and look for stuff that never
successfully loads - such as the sscsdk80.dll.
Source: Charts not showing on report
Also relevant: Crystal Reports for Visual Studio 2005 deployment trouble
have you tried assigning the "NETWORK SERVICE" account write permissions to C:\Windows\system32\inetsrv\dynamic_images ?
is this row present in your web.config ?
<system.web>
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
</system.web>

Web.config overwritten

I have a web.config for my website. I just made a web service which likes to overwrite the previous one. From what I can understand I need an xml transform here. I have read several sites and I am confused as how to complete this. One reference. Would love some insight, thanks in advance.
If you want to add or change something in web.config you don't need any XSL(T) because your output format is still XML.
Transformation (XSLT) is mainly for presenting XML data in different format.
What yo need is basic XML editing functionality. Parse to DOM, add/change nodes, save.

gwt compile to single, monolithic cross-browser html file

I am looking to compile my gwt application into a single, monolithic, cross-browser compatible .html file. Ultimately, I'm trying to design an Amazon mechanical turk template via gwt. These templates must be a single .html file, since they are hosted on Amazon's machines. The .html file can reference external sources, but via absolute address only since I have no control over the file hierarchy.
It does not concern me that the monolithic file will load slower than having separate files for each browser. I am developing a fairly simple web form containing only client-side code that will be seen by very few people. Therefore, speed and cross-browser correctness are not primary concerns.
I have found that by adding the following line to my MODULE_NAME.gwt.xml I can generate a single javascript file that works exclusively for a single browser (e.g. firefox as shown below):
<set-property name="user.agent" value="gecko">
I then embed the generated code into my .html file, and it works for the single browser specified. Unfortunately, when I try opening the .html file in other browsers, the gwt generated javascript does not load.
Is there a linker command that I can add to this file that will do the trick? I tried to invoke the SingleScriptLinker via:
<add-linker name="sso" />
but got the following error:
[ERROR] The module must have exactly
one distinct permutation when using
the Single Script Linker.
I also attempted to tweak the contents of the generated javascript files in order to make them compatible enough to embed in the .html file, but the javascript generated by gwt is too confusing (even in the detailed output mode). Is there a walk-through for how to do this?
I'm using the gwt eclipse plugin on OSX.
As luck would have it, I have found a workaround soon after posting my question:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/79e9634110487490
In short, the answer is to use cross-site scripting.
Add the following line to MODULE_NAME.gwt.xml:
< add-linker name="xs" />
gwt will generate a MODULE_NAME.nocache.js file as well as some MD5.cache.js files (note the MD5 files end with .js, not .html).
Compile your application
Now, put all of these .js files on server A.
Modify your MODULE_NAME.html file to contain an absolute reference to MODULE_NAME.nocache.js on server A.
Upload MODULE_NAME.html to server B.
The cross-site linker makes everything work.

Making Word document embedded in a web page editable or read-only

I'm embedding some Word documents into our web page using iframe like this:
<iframe src="ftp://ftp.example.com/www/uploads/Image/test.doc" width="100%" height="400">
Alternative
</iframe>
The problem is that the embedded Word control allows the user to edit the documents and shows an icon to save them, but doesn't actually save anything. Is it possible to setup Word to save edits back to the FTP server? If not, is there someway we can make the document read-only so the user doesn't get the idea that they can make changes? We're using IE7 and Word 2003.
(I just asked a related question about getting Word to save to a FTP server: Possible for Word to edit documents directly off an web server without Sharepoint?)
You can use ActiveX component like EDraw OfficeView or UltraOffice to embbed office and give you few control against the save and edit the document. You can also send it back to server for save.
There are a number of solutions to your problem, the easiest in my oppinion is a commercial app: https://crocodoc.com/. Developers have unlimited preview time but production use requires a license, don't know if thats an option in your case? To get this working in IE7 you will also need http://html5boilerplate.com/ together with http://code.google.com/p/html5shiv/.
Not sure if this solution will remain free but it is at the moment: https://cloudconvert.org/page/api. They provide an api to convert documents to html, you could write a script to convert docs to html on upload and then store html to show on site.
Another good option is http://www.phpdocx.com/ they have a conversion plugin to convert docx to HTML, pdf and such.
As for making your existing solution read only, i read somewhere you can do it with the method below but i am unable to test as i am on a mac and currently have no access to a machine with IE right now.
<object id="msword" width="100%" height="100%" classid="clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" data='[insert document name].doc'>
<PARAM NAME="src" VALUE="file:////[insert full document path here].doc" >
<PARAM NAME="readonly" value=true>
</object>
Hope these suggestions help you with your project!
I would recommend converting the file to an mht file. this will provide cleaner lines when shown in the browser and prevent the user from editing or saving the file.