Is it possible to import/convert a mod_rewrite .htaccess file to web.config using the command line (NOT using GUI as described here) and how ?
If it is not directly possible is there any workaround for this ?
It isn't possible to do this from the command line. The importer code is part of the UrlRewrite extension code and only surfaced via the IIS manager UI.
That said, if you have .NET Reflector (or a similar tool - ILSpy) you can inspect the code that performs the mod_rewrite translation.
From my own investigations, the UrlRewrite extension lives inside the following assemblies:
Microsoft.Web.Management.Rewrite
Microsoft.Web.Management.Rewrite.Client
These reside in the GAC and can be opened quite easily for inspection by .NET Reflector.
The classes and methods of interest are:
Microsoft.Web.Management.Iis.Rewrite.Translation.ImportRulesPage.Translate()
which calls:
Microsoft.Web.Management.Iis.Rewrite.Translation.Translator.Translate()
From this information it may be possible to reverse engineer your own command line implementation.
Related
The following is a default rule with standard Resharper (without plugins) indicating a naming rule violation.
I would like to understand how custom naming rules are implemented in Resharper using Open API. So would like to deassemble (using Reflector) the corresponding dll file in which this rule is implemented.
Can you pls guide me which dll file(s) I need to check/deassemble for checking how this naming rule is implemented.
Thank you.
Check the ReShaper.Daemon.Specific.dll.
Find there "CheckNamespace" class
I'm using log4net logging in my software that consists of several applications.
I want to have one common library for this.
I created a library and put it in the conficuration file. In AssemblyInfo.cs placed attribute:
log4net.Config.XmlConfigurator(ConfigFile = #"c:\logging.xml", Watch = true)
It work for windows service, but in dosn't work for asp.net application.
It work in asp.net if delete attribute from common library and put in into global.asax. However, this leads to that section of the log4net configuration must be made in the windows service.
There is also a business process which causes our library through the
remouting. I want the logging was carried out there too.
Is there way around this?
In my opinion the library should not define where the configuration file is found. Maybe a better idea would be to have a helper method that allows you to configure log4net quickly; that method would take an optional parameter for the config file path and would try to load the configuration file from the specified path first and if that does not work fallback to some maybe the current folder, the application folder or even the web / app.config.
If you insist that it must be an absolute path then you need to give the IIS Application Pool user read access to this file. This way the configuration by attribute should work for services and ASP.Net applications. I do not understand what you mean by "remounting".
I want to know what is .do extension in web pages. Is it a standard extension, or, if it's not, can we change the extension (like client-login.php to client-login.do and still run as PHP)?
Thanks.
.do comes from the Struts framework. See this question:
Why do Java webapps use .do extension? Where did it come from?
Also you can change what your urls look like using mod_rewrite (on Apache).
".do" is the "standard" extension mapped to for Struts Java platform. See http://struts.apache.org/ .
It is whatever it is configured to be on that particular web server. A web server could be configured to run .pl files with the php module and .aspx files with perl, although that would be silly. There are no scripts involved with most web servers, instead you'd have to look in your apache configuration files (or equivalent, if using different server software). If you have permission to edit the server config file, then you could make files ending in .do run as php, if that's what you're after.
Using apache's rewrite_module can change your script extensions. Give this thread a good read.
Please note. Before anyone tells me about how I should compile the code for performance etc... this is just for a personal project and I want to be able to edit the code in a regular text editor and then it just works.
I usually code in C#, but this would be VB:
I have three files in a Virtual Directory
test.aspx
test.aspx.vb
web.config
I have copied the .Net 3.5 web.config line for line from a File > New Project.
It's not recognizing the XDocument class. Says, it's not defined Since this is a .Net 3.5 class, I figure it has to do with .Net 3.5
So, here's the question: Is this even possible to run a single page without compiling? Asp.Net should compile on the fly. It works with 2.0. Is there something I'm missing?
Just add the assemblies to the web.config file (sorry cant recall the exact place to put it, but a normal VS generated one should have a few entries already).
Anyone have a graphical tool for developing mod_rewrite rules.
Ideally it would display a pipeline of rewrites and then when given an instance of a uri would show the transforms as the get applied.
It's always a pain to get them setup just right so any way of making it easier would help.
For online testing of .htaccess (read: mod_rewrite) rules, try:
http://htaccess.madewithlove.be/
It shows you what and how rules are applied to the input URL.
I dont know of any downloadable tools but there are a few helpful sites that I use to get the basics done:
http://www.webmaster-toolkit.com/mod_rewrite-rewriterule-generator.shtml
http://www.thejackol.com/htaccess-cheatsheet/
I think it’s quite hard to write one. Because mod_rewrite’s behavior is heavily dependent on the environment it’s used in.
Take for an example the -f expression for the RewriteCond directive to test if TestString exists and is a regular file in the file system. How would you do this without the actual file system?
Though the basic behavior (just the RewriteRule directive) could be implemented.
I am not aware of any such tool. The way I've addressed this problem was through a set of unit tests that are checking the correctness of my rules. If you want to have your tests always in synch with the config, you'll have to configure your tests to read the load the rules directly from the config file.
./alex
There is also a new webapp developed by technicalseo.com with help of mwl.be api they have nice gui with same functionality.
https://technicalseo.com/tools/htaccess/
Sounds like you're looking for an app like RegexBuddy.