URL Rerwriting + ASP.NET Image Gallery ajax upload not working - asp.net

I have a CMS that uses HeliconApe to rewrite requests with the following rule
RewriteRule ^/(.*)$ /custompage.aspx?pagename=$1 [NC,L,QSA]
I am also using an image gallery (https://cutesoft.net/ASP.NET+Image+Gallery/) to provide a simple, easy to use image gallery in a CMS and I am having trouble getting the galleries upload to work with Apes URL Rewriting.
When a user requests a page, for example /contact-us.aspx, they are served /custompage.aspx?pagename=contact-us.aspx and /custompage.aspx generates the content, sets the form action to /contact-us.aspx, and adds the gallery with ContentArea.Controls.Add(Page.LoadControl(New DotNetGallery.GalleryBrowser))
When I try to upload a file, for example logo.png, with the ASP.NET Image Galleries built in uploader I see 3 notices in the console
First there is a post to
/contact-us.aspx?UseUploadModule=Dynamic&_Namespace=DotNetGallery&_UploadID=ctl00_ContentPlaceHolder1_ctl02_UploaderImage_1436363874058_1&_UploadControlID=ctl00$ContentPlaceHolder1$ctl02$Uploader&ContextValue=!3wEWAQU1QzpcVXNlcnNcdHdpbGJlcnRcQXBwRGF0YVxMb2NhbFxUZW1wXEFqYXhVcGxvYWRlclRlbXDTV65TuH6b!1qTC8Eov!1tLoCrIFSZy43V46b1KWs!1urZg!2!2&_VFN=logo.png&_Addon=upload&_AddonGuid=d6cd8556-af6f-3785-743f-257780b216b8
If I follow the link I see a file with the following contents but I think that is because I am viewing it without posting my own data (which I dont know how to do?)
<script type='text/javascript'>if(window.parent.CurrentUpload)window.parent.CurrentUpload.UploadError('ctl00_ContentPlaceHolder1_ctl02_UploaderImage_1436361349705_1','Unable to find the uploaded file from StreamManager(sm==null).','')</script>
Then a post to
/contact-us.aspx?UseUploadModule=Dynamic&_Namespace=DotNetGallery&_UploadID=ctl00_ContentPlaceHolder1_ctl02_UploaderImage_1436363874058_1&_UploadControlID=ctl00$ContentPlaceHolder1$ctl02$Uploader&ContextValue=!3wEWAQU1QzpcVXNlcnNcdHdpbGJlcnRcQXBwRGF0YVxMb2NhbFxUZW1wXEFqYXhVcGxvYWRlclRlbXDTV65TuH6b!1qTC8Eov!1tLoCrIFSZy43V46b1KWs!1urZg!2!2&_VFN=logo.png&_Addon=verify&_AddonGuid=d6cd8556-af6f-3785-743f-257780b216b8
Which fails with a 404 and alerts http error1 :404:Not Found
If I change the form action to /custompage.aspx?pagename=contact-us.aspx then the upload works.
I have tried contacting the galleries developers but they have never responded and the live chat isn't very helpful.
So I guess my questions are what might be causing this issue, is there any way to debug proprietary controls contained in dlls, and is there some setting or code I might be missing to make everything play together nicely?
Thanks!

Related

GitHub Page Custom URL Styling and Pics don't render

My site, Jekyll static pages and a blog, https://omnebonum.github.io/dsu/ on GitHub pages looks like it is supposed to (such as it is). I have a custom URL set up that points the repo to democracystraightup.org. That works but when I go that URL the pages show up without any CSS or pics.
I know this isn't super specific information, but you can check them both out if you like, and any general insights would be appreciated.
All your css, javascript and other assets are returning 404 errors:
The paths are all pointing to subdirectories of http://democracystraightup.org/dsu/ (e.g. http://democracystraightup.org/dsu/js/gallery.js).
Thats wrong.
You need to drop the /dsu to make it work.
For example http://democracystraightup.org/js/gallery.js works totally fine.

How to link images and pages in wordpress pages?

So, in the WordPress page, I need to link the pdf in wp-contents so I linked it with the relative URL as href="/wp-content/uploads/2017/03/test.pdf"
when I click it since my root in localhost is localhost/test it takes me to localhost/wp-content/uploads/2017/03/test.pdf (which doesn't serve the file). However, I don't think it'll be an issue in the server. Still, I want to know if this is the correct way?
Also, so I'm in page localhost/test/page22 Now on the page, I have an anchor tag as href="/page23" it takes me to page23 correctly, but when I'm in a different sub page say localhost/test/page/page2 now, the link takes me to localhost/test/page/page23 which is not correct as it should be localhost/test/page23. How can I solve these issues
WordPress provides functions for getting the URL of resources you should use these instead of having your code generate the URL. In this case you should call wp_get_attachment_url().

How to add an HTML class to all image attachments on posts in Wordpress -- except homepage

Sorry for the length, my problem is very simple, but specific.
I'm building a wordpress site that automatically imports image galleries from a Tumblr account, then styles and displays them. The backend is finished, and all that I need now is have all images in posts be displayed as thumbnail sized links. They are not behaving well with the importer (I've tried 6), so I have to edit the HTML display (rather than the images as they are uploaded).
I have decided to do this by applying class="attachment-thumbnail size-thumbnail" on all images on the site (in HTML). I have tested this and they will open the proper gallery in a lightbox as necessary so long as they belong to those two classes.
I have a two part problem.
I do not know PHP past basic syntax, and while I can intuit most of what is happening I don't trust myself to edit Wordpress source code without understanding exactly what I am breaking.
From other answers I've learned that I should most likely edit the wp_insert_attachment() function in post.php under wp_includes/. I have found the function, but don't really know where to go from there, as it does not appear to be specific to image attachments. I don't want to throw any errors by assinging image classes to non-image attachments. How do I add those two classes (attachment-thumbnail and size-thumbnail) to all post images (and only images)?
There is a single exception to this rule. I want a large image on the homepage, and have it not be a link.
It seems like the way to handle this would be to allow page attachments to be handled normally, while attachments that are both images and attached to posts should trigger this:
if [attachment is an image AND is on a post, not a page]:
<img src="https://whatever">
becomes
<img src="https://whatever" class="attachment-thumbnail size-thumbnail">
tl; dnr: ^^ that's all I need to happen, in PHP, in the right file, in Wordpress ^^
Thanks!
So likely you will want to do it via php but instead you could do it with javascript ie jQuery:
<script>
$(function() {
$("body img").addClass("attachment-thumbnail size-thumbnail");
});
</script>
Put that on any page or site header and it will add the class to all images. You can modify the search filter to suit.
You might need to re-call your lightbox initialization code too, or put this before it gets called initially.

Code needed for htaccess redirect in WordPress

I've been fixing a strange htaccess issue on my client's WP sites. I found a solution by putting the ReWrite code in the htaccess of each site and then adding a custom permalink code in permalinks and it seems to work EXCEPT for one section.
There are a total of 9 sites with this issue. All of them have a highlights plugin on the front page that's pulling story and images and displaying them on the home page and then a link that goes to the story full page. For my above permalink fix, out of the 9 sites, my fix works on 5 of them but on 4 of them in the highlights section, when you click a link I'm getting a 404.
The strange thing is, with my above fix, the highlight page still publishes, but not with my fix. For example, when you click the "fixed" link it should open as:
mysite.com/central/index.php/highlights/my-page
...but I get a 404. But all I have to do is delete the "index.php" in the above, and the page itself still works:
mysite.com/central/highlights/my-page
So what I now will do is write re-write code and put it in the root htaccess file so that when the page:
mysite.com/central/index.php/highlights/my-page
...is called it will re-write to:
mysite.com/central/highlights/my-page
...and that should fix this pesky issue. Here's the catch - I'm not good at writing code and I used my own hosting company's re-write generator to create a sample for me to see but I can't use it to generate what I need because it only generates for my domain. Since I don't know how to post code to this forum, below is a snap shot of it:
http://designerandpublisher.com/images/rewite-code.jpg
Is there a place where I can just copy and paste the URLs and it will generate the code so it looks like the above snap shot? Or is there some kind of tutorial of what / and \ and dollar signs and the periods and why they're there? I used to set up redirect code a lot simpler than this but it seems more complex now and i'm just hoping there's some kind of generator? Thanks for any assistance.
Adding the following rule should work:
RewriteRule ^central/index.php/(.*) /central/$1 [R=302]
it should turn mysite.com/central/index.php/highlights/my-page to mysite.com/central/highlights/my-page
(Change R=302 to R=301 when you are sure the redirect works)

Image disappear when url route

I am writing a web page to show image (image is dynamically generate by .Net charting) in a web. I have used the asp.net web forms URL routing to navigate to this page. Once I use the URL routing the image appear on the page. Anyway this is working fine for normal page browse.
More than likely your link to the image is using a relative path, and once you introduce routing you are working with a URL structure that appears to be deeper nested in the folder structure than it is.
When linking to the image for display I would recommend using root relative path something like /Images/MyFile.jpg rather than ../Images/MyFile.jpg, or similar.
This way if your route changes, and additional "folders" appear in the route, the link will still work.

Resources