How to implement integrity control of web applications - asp.net

Any web application (for example asp.net/asp.net mvc) contains many *.dll, *.js, *.css, *.aspx, *.ascx, *.cshtml and other files.
We need to implement mechanism to control integrity of all these files to quickly analyze was modified any file or not after deploy.
So, we can on continuous integration server generate file with hashes of all files, put it into some dll of project as embedded resource, and sign dll via strong name. Then in every time we can check integrity of dll and validate hash of all files.
Is there a more simple solution? Or ready to use third party solution?

Related

What is the alternate of web.config file in asp.net core

I am started working on asp.net core web application and there is no web.config file in this project. Here is appsettings.json file though. I don't know where to store confidential information (like we store username and passwords of domain in web.config file in .Net Framework). Is it safe to Store confidential data in appsettins.json file?
Yes appsettings.json is like web.config for ASP.NET Core. It’s for storing non secretive data. But there are multiple ways to configure your app, e.g. environment variables, command line arguments, as well as appsettings.json. You can also configure each environment with this file.
You should not store secrets like usernames, passwords or API keys here, as this file gets checked into source control and you might leak these to other parties. You can use User Secrets (only in development) or Azure Key Vault for secretive settings.
This is a big topic so it’s better to check the docs on this, and see which provider(s) works best for your scenario.

How can I structure my architecture server project?

I'm working with Silverlight. In it, I've created a web project.
I always have created desktop application where I divide my projects in three modules:
Domain
Application
Presentation
But now, I'm working to the server side and I really have no much idea about how to build my architecture. In it, I plan to have a entity model for my database.
So, can you give some ideas about the modules how to structure?
I structure my Silverlight server-side libraries as follows:
MyApp.Host: The main hosting project for the silverlight application. Brings in fact nothing more than the aspx file housing the XAP and the ClientBin folder containing the XAP files. Additionally you can use a global.asax file to run a bootstrapper or any other components needed to startup your server-side application.
MyApp.Server.Services: This project contains all my domain services. The client side libraries have a RIA-Services link set to this project
MyApp.Server.Data: This project contains my Entities, and my data-access-layer, such as database contexts or repositories encapsulating the database access.
Note: This structure is for RIA-Services applications. When using other service types you might want to have a portable library called MyApp.Interfaces for accessing services and entities.

Resources in ASP.NET (VB)

I have added a resource file in App_GlobalResources called FileList.resx.
Now I access the contents within the code by using
My.Resources.FileList.astro1 etc.
It works fine if I set the Build Action of resource file to Embedded. However in this case the resource file is not available after compile and I can't change it later.
If I set the Build Action to Content I get an error : Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "WAP.FileList.resources" was correctly embedded or linked into assembly "WAP" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Please advice me.
Are you using a Visual Studio Web Application? Or a Web Site?
In the latter case, you should be able to change the Resource file after deploying the site, and it should get automatically recompiled on the server. In the former case, it's a built-in that can't be changed after the site is compiled before deployment.
If that's a problem for you, there are of course alternatives to Resource files....
In any way of compiling and deploying your application all resource files will compiled in related to each resource file assemblies. In all cases, resource assemblies are ultimately created for each directory in the site, and satellite assemblies are generated beneath their respective culture-specific directories. Even when the site is JIT-compiled, the outcome is equivalent.
So, you must use Build Action of resource file to Embedded, but as possible solution for dynamic resource definition you can place you resources in a database. And even provide a Resource provider. In that case your database solution would have all the benefits that suggested by resource management aka dynamic culture definition, using resource binding to control, etc.
Here you can find some tutorials how to implement Resource-Provider Model in your application:
Extending the ASP.NET 2.0 Resource-Provider Model
Creating a Data Driven ASP.NET Localization
Resource Provider and Editor

problems when make a web service as an alternative to dll

Q:
Recently , i face some problems, i have a dll common among a lot of applications,and any change to this dll require to build it, copy and paste it in each bin folder of these applications ,and add the new reference so i decided to convert this dll to a web service in stead to overcome this overload..
I make a web service application contains set of web services(mapping to each class).
I face some problems here:
In the original dll, there are
classes use methods exist in other
classes in the same dll, and i face problems when i
tried to use web service methods in
other web service class.how to fix
this problem.
In the original dll there are set of
static classes with static
methods.how to make the equivalent in
my web service application.
Any overload method cause a problem
in my web service.
When using Dictionary<string, string>
as a parameter in my method.
Note:the original dll contains the connections to the data base. Is converting it to web service is the optimum solution?which one is faster in my case a web service or the dll?Should i tend to WCF instead of?
thanks in advance.
In my applications I usually have all related projects in the same solution. But when I need to use projects across applications I replace the project for a dll reference.
Because I use Subversion I solve the problem of copying the dll by adding an external property do my libs folder, referencing the build of the dll.
If the external dll is updated very often than you probably need a continuous integration system to handle that for you.
I usually add project reference and keep all my projects under single solution, so I do not have file copy issue. You might be missing project reference, instead you could have used assembly reference. Verify that first.
First advice, don't create a web service if you don't know what it is and how it can be used. People tend to think everything is a web service since creating a web service in WCF is so easy by using visual studio tools. Since you ask like converting DLL to a web service, I assume that you are beginning with learning web service.
All you need is kind of continues integration system otherwise a simple build system which does the build for you and it copies the files wherever depended applications folder. Hence you can save your time for coping files manually. When you do this, you will not have any of those 4 problems you have mentioned.
If you are lazy enough to learn the build system, simply write a batch file that would copy the files for you. I do have batch files which does xcopy files.

ASP.NET plug-in architecture, settings problem

I want to divide business layer (BLL) of an asp.net application into multiple components. Each component is a .NET class library which is compiled as a standalone DLL. These components should have their own configuration files. For example "MyNameSpace.Users.dll" contains classes about users of the website and there's a password policy to check if password length is at least x characters. When webmaster edits the config file of this DLL and set x to y then component (DLL) should use new value (y) in the future and enforce passwords to be at least y characters. I want each component as a single project and compile them separaely (and not to put all projects in a solution in Visual Studio), and put the DLLs of these libraries into the "Bin" folder of my ASP.NET application.
Is it possible ?
Where should I put these config files ?
Managed Extensibility Framework (MEF) released in .NET 4.0
http://mef.codeplex.com
imho It's possible but not out of the box.
ASP.NET uses by defautl only the one web.config in the web root (and pproriate machine .config files higher up in the hierarchy). But you can create custom settings providers for each of your dlls that read values from separate .config files.
see http://msdn.microsoft.com/en-us/library/ms228060.aspx
This way you create different SettingsManager providing settings to parts of the App and reading the info from files.
Plus you can use FilesystemWatcher to reload values when the additional .configs are edited.

Resources