disabling mod-security cpanel - c#

I developed a Sync. software based-on C#.
it read some values from database and make a string as url.
then call a url with WebClient and pass url with values.
at the server,i wrote a php page that use $_GET to fetching the values,then insert them to
mysql database...
for first record,that's work,but after that my program ends with 406-Not Acceptable exception.
after some searches i know the modsecurity in the problem.and i try to disable that.
so,i add these line to .htaccess file:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
SecFilterInheritance Off
</IfModule>
but it doesn't work...
i try to solve that and i was found my cpanel is cpanel accelerated2...
so i change code to :
<IfModule mod_security2.c>
SecFilterEngine Off
SecFilterScanPOST Off
SecFilterInheritance Off
</IfModule>
but now,with this change,all of my pages doesn't work and i get error 500...
and now i like some one help me...

The directives you are trying to use won't work in a .htaccess file, they need to be added to the VirtualHost definition for the site you want mod security disabled for and the best way to do that with cPanel is to use a separate include file.
You can edit httpd.conf directly to add the include file and then update the changes with the cPanel httpd.conf distiller /usr/local/cpanel/bin/apache_conf_distiller --update . If you don't have root level access to your server your host should be able to do this for you.

Related

CSharp Adding my site url path to the front of a Hyperlink

I am having an issue. I have page urls coming in as strings from my DB via csharp access identifier.
Example of cshtml line:
#data.PageTitle
When I try to click on the link the link appears as:
https://www.MyAPP.com/dmr/home/www.LINKURL.com
How to I get the clickable anchor tag to only display
www.LINKURL.com
Any ideas or guidance would be appreciated. Thank you.
Nothing to do with Razor or C#.
The browser doesn't know that it's a domain - it is interpreting it as a file path. Use a protocol http://, https:// or // (this means use the same protocol as the current page).
You might consider adding data validation before saving potentially invalid URLs in your database.

To Modify the .htaccess for 301 Redirect with Asp.net on the fly (Dynamically)

I make changes using Cpanel / Redirect manager of a Site.
Based on the Changes made on Cpanel for URL redirection, i.e. Say Old Url -> Current Url, I want to modify the .htaccess file dynamically. How do I achieve this using Asp.net?
I assume you want to do URL redirection in ASP.NET. See more information about this topic. http://www.iis.net/downloads/microsoft/url-rewrite.

How to add an download link to users in my project

In my project i will be having an link like
Download
I want the users to download files of different types. The file will be in the root folder. When i am clicking on the link it is displaying an error. This is the plugin to install in the chrome. If the user download this link and open then it will automatically add to the chrome.
How can i do this.
The file is not even downloading.
This isn't a valid path:
~/hello world.crx
The ~ character is for use server-side to denote the root of the application. Client-side it has no meaning. The browser doesn't know what the root of the application is (or what the application is at all), it's just sending requests to resources at addresses. And it doesn't know what to do with that address.
You'll need to either use some server-side logic to translate that path into a browser-useable path, or manually make it a relative or absolute path.
If the ASP.NET MVC Framework isn't translating this for you then you're probably using a version that requires a little more manual work for it. Try something like:
Download
(Note: This assumes the use of the Razor view engine. If you're not using that then you'll want to use whatever your view engine equivalent is.)
What you need to do is set up a directory online, where you can host the file.
I also see that in your aref you don't want to type the full path so denote it with a /hello_world.crx, but make sure that you've set up a base href:
<base href="http://yourdomain.com/something/">
Try renaming the file to remove any spaces e.g. "hello_world.crx" and then change the name in the link code to match.
if a webpage and the downloadable file is in the same location
(i.e)
SampleFolder->Download.html
SampleFolder->hello world.crx
then try the below
download
If the webpage and the downloadable file in different location
(i.e)
SampleFolder->Download.html
SampleFolder->Downloads->hello world.crx
then try the below
download

HTTPS Display Mixed Content Error. Anyway to programatically handle this? or change the text of the error?

I have a HTTPS silverlight application (Finally), but i also have a call to get some map data from a non https website.
The issue is this call to the non https map data, which just consists of images (map tiles) and a list of countries. It displays a note to the user saying that the page contains unsecured(mixed) content, and would they like to display it.
** The map data is hosted on a internal server on the network and is 100% trusted and secure content. **
My question is are these three:
Is there anyway i can tell the user that the unsecured content is only map data and will only be pulled to the client once, and if they want to see the map in the application, they should press accept?
Or is there a way to display a custom message to the user from silverlight and store their decision to hide or show the "unsafe" content in the app ?
Or is there a way in the config files to specify a set or URIs that are safe and can be ignored when the browser is doing its mixed content check? Like if i wanted to specify a safe URI of http://mapdata.com/mapdata, could i do this along with some https setting in the webconfig file in silverlight?
Thanks for any help and time.
For security reasons, no you cannot overwrite that warning message. Imagine if a malicious site overwrote that message to say nothing was wrong? It's meant to be something developers can't mess with.
What you could do instead is tunnel the HTTP content over some HTTPS tunnel (maybe stunnel?). This will have some performance ramifications, but it should solve your mixed content issues.

asp.net and c# with javascript

((LinkButton)e.Item.FindControl("my_label_name"))
.Attributes.Add("onclick","javascript:myJavaScriptFunction('"
+ data1_from_db + "','"+data2_from_db+"')");
I wrote this code (this code is in my default.aspx.cs) and this worked successfully at localhost but at server didn't work. And gives no error about working. Just it doesn't work. If any incomprehensible places have, please, ask me.
My guess would be that the call to the myJavaScriptFunction is probably failing. Your javascript file (.js) is probably either not included or not marked as content within the project and would not get copied as part of the server installation.
EDIT: Based on your comments to my answer, it seems that your javascript (.js file) is being included and called on your server. If that is true, it is possible to debug your javascript by either using (IE Developer Tools - F12) or something like FireBug in FireFox to see what's happening within your javascript.
Is that part of code an update you made to your page that was already on the server? If so, just try clearing your cache. This just might work.
Double check that there is data on the server side. Say for example you are pulling info from localhost and everything is fine because that data does exist in the database on your local machine, however this data may not exist on the server's database. Double check to make sure it does and that the table name / info matches and so does the connection string.

Categories

Resources