Category Archives: .net

Get Data from other URL in C# or AngularJS

I need data from another Hadoop API url. But I only get html source code without the data. I am using the following code.

using (var client = new WebClient())
{
    String downloadedString = client.DownloadString("http:........");
}

Actual Result:

<tr><th> Configured Capacity:</th><td> *{Total|fmt_bytes}* </td></tr>

Expectation

<tr><th> Configured Capacity:</th><td> 55 </td></tr>

I need 55 in my c# code.

My expectation is possible?If yes please guide me.

"this content cannot be viewed in a frame" error the first time I load the page

I have developed a search form which is hosted in a local server (iis, net core web site) in my company. The web site is a Wordpress hosted in another server (apache, wamp), also in the company. Both has different public IPs, but both are hosted under subdomains of the same domain.

say, wordpress.company.com and search.company.com, and I have control over both.

first time I tested using iframe plugin, everything seem to work ok, however I realized now, there is this error shown in Edge. Same behavior is shown on all browsers yet no similar messages are shown.

This content can’t be shown in a frame

There is supposed to be some content here, but the publisher doesn’t allow it to be displayed in a frame. This is to help protect the security of any information you might enter into this site.

Try this

Open this in a new window (which is a link to iframes content url)

The weird thing is I just have to press F5 and everything loads correctly.

The error in the Chrome console is:

Refused to display 'http://subdomain.mysite.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

How can I workaround this behavior?

How to attach/connect to exising Ignite node

Getting a "Failed to get default Ignite instance: there are no instances started." when trying to connect (using Ignition.GetIgnite()).

More Information:

I am trying to use Apache Ignite as my in-memory database. My plan is to start the Ignite instance in a server and then make the application connect to that. I started apache ignite from commmand line with the default configuration

    ignite.bat   

Then, from my .NET application, I tried to GetIgnite so it would connect/attach the existing ignite node, since both were in my local machine.

    var ignite = Ignition.GetIgnite();

This is the configuration I have in web.config

    <configSections>
<section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
 </configSections>
 <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
                    localhost="127.0.0.1" peerAssemblyLoadingMode="CurrentAppDomain">
   <atomicConfiguration atomicSequenceReserveSize="10" />
 </igniteConfiguration>

Working Version: I could start "Ignite" from within the application and perform in-memory database operations like caching data with different ICache and later join to retrieve data. But this version will not be scaleable.

     //for some reason I have to set the environment variable like this
     Environment.SetEnvironmentVariable("IGNITE_HOME", "C:\\test\app\\packages\\Apache.Ignite.2.4.0\\");
     // Start Ignite and retrieve cache
     _ignite = Ignition.StartFromApplicationConfiguration();

     CacheConfiguration config = new CacheConfiguration("MyProduct", typeof(MyProduct));
     config.CacheMode = CacheMode.Local;
     ICache productList = _ignite.GetOrCreateCache<string, MyProduct>
                                    (config);

301 Permanent Redirection, Urls are not changing

I am implementing 301 redirection, but the problem that I am facing is, the urls are not changing, and when I implements 302 url start changing, is their any way through which I will implement 301 and the urls will change as per the need.

Like: www.abc.com and abc.com. I need only one URL to display in my browser when I hit anyone of the above mentioned URLs.

Thank you!!

publish asp.net project on apache server

I am new to .NET and I have downloaded a project from github that I want to run on localhost apache server. I found a lot of information on the internet on how to use .NET for apache Server (mono etc.) and everything seems to be installed correctly and I am rather unable to find an answer to the basic question on how to access the project's web UI from the browser. I am used to php and html and therefore was looking for an index-file which I cannot find in the project folder structure. What am I missing?

Thank you so much for all your help. Steffen

Apache2 + Ubuntu + Mono: Issue with System.Web.ActiveDirectoryProvider

Apache2 + Ubuntu + Mono: Issue with System.Web.ActiveDirectoryProvider

When my web application trys to use Active Directory Authentication I get the following: Web Page Error

When I look at the logs under /var/log/apache2/error.log I have this:

[Fri Jan 27 10:14:31.160499 2017] [mpm_event:notice] [pid 17187:tid 140082060339072] AH00491: caught SIGTERM, shutting down
mod-mono-server received a shutdown message
Invalid type System.Net.Http.Formatting.MediaTypeFormatter for instance field System.Net.Http.Formatting.MediaTypeFormatterMatch:<Formatter>k__BackingField
Invalid type System.Web.Http.Controllers.HttpActionContext for instance field System.Web.Http.Filters.HttpActionExecutedContext:_actionContext
Invalid type System.Web.Http.Controllers.HttpActionDescriptor for instance field System.Web.Http.Controllers.HttpParameterDescriptor:_actionDescriptor
Invalid type System.Web.Http.Controllers.HttpActionContext for instance field System.Web.Http.Validation.ModelValidatedEventArgs:<ActionContext>k__BackingField
Invalid type System.Web.Http.Controllers.HttpActionContext for instance field System.Web.Http.Validation.ModelValidatingEventArgs:<ActionContext>k__BackingField
[Fri Jan 27 10:14:33.263821 2017] [so:warn] [pid 17361] AH01574: module mono_module is already loaded, skipping
[Fri Jan 27 10:14:33.268918 2017] [:error] [pid 17366:tid 140510323828608] Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_global --nonstop --master (null) (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory
[Fri Jan 27 10:14:33.272467 2017] [:error] [pid 17370:tid 140510323828608] Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_global --nonstop --master (null) (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory
[Fri Jan 27 10:14:33.273501 2017] [:error] [pid 17362:tid 140510323828608] Not running mod-mono-server.exe because no MonoApplications, MonoApplicationsConfigFile or MonoApplicationConfigDir specified.
[Fri Jan 27 10:14:33.274003 2017] [mpm_event:notice] [pid 17362:tid 140510323828608] AH00489: Apache/2.4.18 (Ubuntu) mod_mono/3.12 configured -- resuming normal operations
[Fri Jan 27 10:14:33.274016 2017] [core:notice] [pid 17362:tid 140510323828608] AH00094: Command line: '/usr/sbin/apache2'
Listening on: /tmp/mod_mono_server_beta.medialabstage.com
Root directory: /var/www/beta.medialabstage.com/
[email protected]:/home/mladmin#

Any idea what is going on? I have used different DLLs for system.web.dll from .NET package and the windows Mono package.

Reverse Proxy Apache Kestrel

I have .net core web API hosted on Ubuntu machine and I am trying to setup reverse proxy using Apache server. I have successfully setup reverse proxy for port 80 i.e. HTTP but I am facing issue while accessing my API using port 443 i.e. HTTPS. I am able to access only API's root URL i.e. home page using HTTPS but while accessing any controller methods gives 404 Not Found error. For example:

https://someapi.com -- works

https://someapi.com/user/1 -- 404

Error is: The requested URL /user/1 was not found on this server. Apache/2.4.18 (Ubuntu) Server at {SERVER_NAME} Port 443

Here is my reverse proxy configuration:

<VirtualHost *:80>
    ErrorLog /var/log/proxyerr.log
    ProxyPreserveHost On
    #proxy for /
    ProxyPass / http://{SERVER_IP}:5000/
    ProxyPassReverse / http://{SERVER_IP}:5000/

    #proxy for other ports
    ServerName {SERVER_NAME}
</VirtualHost>

<VirtualHost *:443>
    ServerName {SERVER_NAME}    
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>    
    ProxyRequests Off
    ProxyPreserveHost Off
    ProxyPass / http://{SERVER_IP}:5000/
    ProxyPassReverse / http://{SERVER_IP}:5000/
    ErrorLog /var/log/proxyerr.log  
    SSLEngine On
    SSLProxyEngine On
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:!RC4+RSA:+HIGH:+MEDIUM:!LOW:!RC4
    SSLCertificateFile {CERTIFICATE_LOCATION}
    SSLCertificateKeyFile {PRIVAKEY_KEY_LOCATION}
 </VirtualHost>

I referenced many different articles and checked out many links in attempt to resolve issue.

Please advice why am I getting 404 errors on all secured API calls? Thanks!

Detecting changes in SQL Azure, and publishing events

My company is currently using event sourcing pattern in our system. The system usually publishes events from applications, and then stores them in event store and at the same time update database (for query) via event handler. However, there are exceptional cases where database (which is SQL Azure) is updated without publishing events and updating the event store. To keep integrity of event store, I would like to detect changes (from the aforementioned cases) in SQL Azure and send events to event store for backfilling.

I checked there are couple of ways in .NET to achieve it using SQLTableDependency or websocket to detect SQL CDC (Change Data Capture). I found SQLTableDependency doesn't support SQL Azure.

I wonder if someone has experience in the similar technical challenge.

How do i deploy .NET projects on a Linux Server(Webmin)

So,this has been bugging me for quite sometime,i tried a lot of solutions that are there on the internet and its not working out Tried mod_mono,Mono,Docker,nginx

I can compile a Dotnet project,but i'm not able to put it onto Internet Hosting,like i can navigate to the folder which has all the files and all but the services like WebAPI and other things aren't getting triggered Any help would be deeply appreciated,btw i have a Webmin Server Management on top of it