I am currently dumping all my logging into Log4Net text files, and they are difficult to read. Is there a nice log4net processor (preferably a class I can add to my ASP.NET app, so that I can view logs remotely) that will lay out the log4net dump in a nice, easy to read and search format?
There is an Apache tool for log4j called Chainsaw which can apparently be used with log4net log files (instructions here).
There is also a commercial tool called Log4Net Dashboard which can also do it.
Neither of these are web-based though.
There was a tool called log4xsl a while ago. If you configured log4net to output XML log files, you could apply the log4xsl XSLT stylesheet to render it nicely in a web browser. The project seems defunct though, but you could try to find it somewhere (here may be a good starting point).
Log2Console can read log files, but you can also use it to monitor "live" events throught .Net Remoting or UDP Appenders. There is also a commercial tool "Log4View" that can to the same.
In your case logging to a database would make the most sense though. You can access it easily remotely and filtering is certainly no problem. Building a ASP.Net page with a data grid would be done very quickly so that you do not need to access the database directly.
Related
I'd like to build a spider tool using which I can run it against a website root url then it should find all the broken and healthy links (images, css, .aspx, .docs) by specifing the degree of parsing e.g. 2 levels.
Then at the end it should generate a map of the result either in Xml or in DataTables
Is there any ready third party or free tool that I can reuse in my .NET application?
Many thanks,
I've used the Chilkat ASP.Net Spider component before. It allows you to specify the number of levels to crawl, and allows you to set up exclusions etc.
It won't generate a map for you automatically (or at least the version I worked with didn't), but logging the results to either a database or XML should be fairly easy. Details on the component can be found here, and you can download the component for free from here
Informative
I'm working on a project that loads a binary file from the disk. This file has a specific structure to store data and I need to protect this file from being loaded if the data was generated/tampered by third parties.
Resume
I have a file that I must check if the "creator" is me before loading.
Project Specification
The application that loads the file is written in C++.
The application that generates the file is written in C#.
Question
What are my options to accomplish this?
What libraries/algorithms to use?
Can you provide me some steps or guides?
Notes
I have Crypto++ linked to the C++ project if it helps.
What you are looking for is a signing/certifying system wirth asymetric keys. The functionality is built in .Net. A Quick google search shows this example which looks legit.
Keep in mind though, that if you don't have the full control of the certification process (if your application is on a client's computer), someone might decompile the code to bypass the check.
quickly like that i would take a look at LZMA SDK since the SDK support c++ and C# and just compress/encrypt the file
maybe there is a better solution, but this would be my first try
In the past I have used asp.net's built in Resource files for handling localization. It's worked pretty well and we find it easy to use and maintain in our business.
There is one big drawback though - our client's support teams can't update the resource files themselves. We have a big project starting soon and the option to allow the external support team manage localization is a main requirement. Up until now we have had clients just contact us, we get the piece translated and then roll the updated resx file to the live server.
I know that updating a resx file causes the application to recompile and I don't like the idea of allowing non techies download and mess around with a resx file (not to mention having the site uncompiled in a live environment) so I'm wondering if there are any other options available to us other than going down the database route?
If we do have to build this type of localization functionality into a few database tables, does anyone have any good templates for starting off?
Not sure if it helps knowing or not but the site we're talking about building here would be localized into about 15 different languages including chineese and arabic. The translations would be applied onto the aspx pages and in the XML that would leave our system to third parties.
Whatever you do, you will probably need to write custom ResourceProvider.
You may think of using XML as a source for your localizable resources - in that case you can use uncompiled resx files, but I guess that is what you are complaining about. Otherwise, you can use bundle files, similar to Java properties, I mean plain text file with key=value pairs. That should be very easy to edit.
Sure - use a config file. This is basically an XML file.
<messages locale="DE">
<message id="FileNotFound" Value="Die Datei wird nicht gefunden" />
<message id="FatalErr" Value="Es ist ein schwerwiegender Fehler gewesen. Das Programm muss beendet." />
...
</messages>
You can have one file for each language, or combine them in one file.
Believe it or not, you're not the first one with the idea! :) Here's an article I found a few years ago on how to implement a custom resource provider for .NET. You can keep your old resource-based approach in your code, and have the provider take the data from wherever you like.
Instead of writing your own resource provider maybe an online translator like ResX Online Translator would help? The translators don't have to download any resx, and the files are automatically uploaded to your live (or dev) asp.net application.
Use Microsoft MAT or write your own provider for MAT. More info on their website: https://developer.microsoft.com/en-us/windows/develop/multilingual-app-toolkit ;-)
We all know that it is possible to "open" a Word document (or file from any arbitrary application) by clicking on a website link and then clicking the Open button.
I also know that, if I want to upload an application document to a web server, I must first save the document to my computer, and then go to an upload page, click a file/open button, find my saved file and upload it.
But is it possible to save a document to a website location or Url, effectively skipping the first save step and uploading the file to the web server through the Save dialog of the application, directly?
How would this be done in ASP.NET MVC?
It really depends on how complex you want to make it. This is pretty much what "web folders" offered (via WebDAV), but in general it creates more problems than it will ever fix. I don't recommend this approach.
Your best bet to make this simple is a dedicated client app - perhaps (although this is a dubious example) how Office talks to sharepoint. In a simpler example, you could create a silverlight out-of-browser application that saved via a web-service to a site using WCF or similar.
I think there is some creedence in what #Marc says. Personally I'd probably map a drive to the web site in question, if that's possible, and have a folder to upload to.
Then I'd have .Net check changes to the folder and take those files and import them into the repository, whatever that may be.
It's still an imperfect solution and I'm not sure there is a correct solution as yet.
I guess you could always write, and I can't believe I'm writing this, macros to save to the ftp location.
I'd guess you have a few choices, in no particular order:
Web service that the application can reference and upload through.
REST service (WCF or otherwise) that the application can POST to.
HttpHandler or MVC controller action that the application can POST to.
WebDAV directly to the server.
Number 3 sounds like it's closest to what you were looking for ("How would this be done in ASP.NET MVC?"). Scott Hanselman has a good article on handling file uploads in MVC on his blog.
When you implement the client, there's a little bit of a trick to that, too, since you can't just POST like usual; you have to post in multipart/form-data format. I posted a blog entry with some sample code on how to do that.
Can I communicate to Google Chrome in C#?
For writing a chrome plugin for example.
<Spoilers>
Quick short answer: No, because Extensions require JSON, JavaScript, and HTML.
</Spoilers>
Hi Tony,
There are multiple templates on the internet that you can download to build a chrome extension project using Visual Studio.
Downloading one of these templates just gives you the files and folders that you need which I call "the setup".
That won't let you build a Google extension using C#.
Andrey mentioned that there are libraries like Bridge.NET that will compile your code into HTML/JavaScript. That will help you write HTML and JavaScript using C#. You still need a manifest.json file.
I don't recommend that. That library is not designed for Chrome Extensions. Also, you will have to compile the code into JavaScript and store that JavaScript code in a JavaScript file. I recommend using HTML/JavaScript with no compilers when building your Chrome Extension.
You need to keep in mind that there are 3 main parts in a chrome extension. These are:
manifest.json
A JavaScript file
HTML file
There are multiple steps and it's not hard to build a google chrome extension. This link will give you the complete tutorial on developing a chrome extension with detailed explanation. This tutorial installs a template so that you can develop it in Visual Studio just like I mentioned before.
What I have done to address is use Simple Message Host, it will trigger an executable on the local machine that you code in c#, sending stdin messages and listening to stdout messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network at least, and you have to do some editing in the windows registry, so it has its limitations.
But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.
So, just to clarify, what I did here is:
Create a chrome extension with background.js opening up the listener to the website's javascript.
Add a registry in windows registry pointing to the path of the executable.
Create the executable in C# doing all your logic.
Send a response from the executable to the extension and then back to the website.
There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.
But for the moment, it is the best way to do what you want, if you have control of your environment that is.
So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce perhaps or WebAssembly but that's not fully released yet.
Chrome own extension manager supports extensions written in js and html.
that said, to execute c# code within the extension you have two options:
Compile c# code to javascript code which then can be added as a normal javascript extension to chrome (take a look at scriptsharp)
Use c# as a back-end system. just like most of download managers:
for case 2 you need a c# application installed in client device(or in the cloud) listing to a specific port (using httplistener or self hosted webapi (you can use netcore) which do these steps
Listing to incoming requests
parse request data eg. json and do something with it
return the result to javascript extension which can display it to user or do other things with it.
The topic is quite old, but I'd like to share that sample:
https://github.com/Retyped/Demos/tree/master/ChromeDemo
In a few words, the sample is implemented in C#. The Retyped.chrome NuGet package provides bindings (Chrome API) for Bridge.NET projects. So yes, now you can implement your logic in C#, then C# code will be transparently compiled into JavaScript by Bridge.NET compiler.
With that approach you can build your Chrome extension on top of .NET Framework as well as utilize thousands of JavaScript libraries.